53 lines
1.1 KiB
Rust
53 lines
1.1 KiB
Rust
use serde::Deserialize;
|
|
use crate::Architecture;
|
|
|
|
#[derive(Debug, Clone, Deserialize, Default)]
|
|
pub struct Config {
|
|
pub mirror: Option<MirrorConfig>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Default)]
|
|
pub struct MirrorConfig {
|
|
repos: Vec<String>,
|
|
mirrorlist: Mirrorlist,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Deserialize, Default)]
|
|
pub struct Mirrorlist {
|
|
pub x86_64: Vec<String>,
|
|
pub aarch64: Vec<String>
|
|
}
|
|
|
|
impl Mirrorlist {
|
|
pub fn for_arch(&self, arch: Architecture) -> &[String] {
|
|
match arch {
|
|
Architecture::x86_64 => {
|
|
&self.x86_64
|
|
},
|
|
Architecture::aarch64 => {
|
|
&self.aarch64
|
|
},
|
|
Architecture::any => {
|
|
&self.x86_64
|
|
},
|
|
}
|
|
}
|
|
}
|
|
|
|
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<&Mirrorlist> {
|
|
if let Some(mirror) = &self.mirror {
|
|
return Some(&mirror.mirrorlist);
|
|
}
|
|
|
|
None
|
|
}
|
|
}
|