use serde::Deserialize; use crate::Architecture; #[derive(Debug, Clone, Deserialize, Default)] pub struct Config { pub mirror: Option, } #[derive(Debug, Clone, Deserialize, Default)] pub struct MirrorConfig { repos: Vec, mirrorlist: Mirrorlist, } #[derive(Debug, Clone, Deserialize, Default)] pub struct Mirrorlist { pub x86_64: Vec, pub aarch64: Vec } 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 } }