This commit is contained in:
parent
cd3122e6c0
commit
4e125c611c
7 changed files with 116 additions and 78 deletions
|
@ -1,4 +1,5 @@
|
|||
use serde::Deserialize;
|
||||
use crate::Architecture;
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Default)]
|
||||
pub struct Config {
|
||||
|
@ -8,7 +9,29 @@ pub struct Config {
|
|||
#[derive(Debug, Clone, Deserialize, Default)]
|
||||
pub struct MirrorConfig {
|
||||
repos: Vec<String>,
|
||||
mirrorlist: 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 {
|
||||
|
@ -20,9 +43,9 @@ impl Config {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn mirrorlist(&self) -> Option<&[String]> {
|
||||
pub fn mirrorlist(&self) -> Option<&Mirrorlist> {
|
||||
if let Some(mirror) = &self.mirror {
|
||||
return Some(mirror.mirrorlist.as_slice());
|
||||
return Some(&mirror.mirrorlist);
|
||||
}
|
||||
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue