31 lines
653 B
Rust
31 lines
653 B
Rust
|
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
|
||
|
}
|
||
|
}
|