pacco/src/config.rs

31 lines
653 B
Rust
Raw Normal View History

2025-01-13 11:39:00 +01:00
use serde::Deserialize;
#[derive(Debug, Clone, Deserialize, Default)]
pub struct Config {
pub mirror: Option<MirrorConfig>,
}
#[derive(Debug, Clone, Deserialize, Default)]
pub struct MirrorConfig {
repos: Vec<String>,
mirrorlist: Vec<String>,
}
impl Config {
pub fn is_mirrored_repo(&self, repo: &str) -> bool {
if let Some(mirrorc) = &self.mirror {
return mirrorc.repos.iter().any(|x| x == repo);
}
false
}
pub fn mirrorlist(&self) -> Option<&[String]> {
if let Some(mirror) = &self.mirror {
return Some(mirror.mirrorlist.as_slice());
}
None
}
}