use std::collections::HashMap;
use std::convert::TryFrom;
use super::{ConfigTrait, TargetConfig, Target, OS};
use super::build_os;
#[derive(Serialize, Deserialize)]
pub struct Config {
pub release_path: String,
pub license: String,
pub readme: String,
pub config: HashMap<String, HashMap<String, TargetConfig>>,
}
impl ConfigTrait for Config {
type Previous = super::EmptyConfig;
fn targets(&self) -> Vec<Target> {
let mut targets = Vec::new();
for (os, value) in self.config.iter() {
let opsys = OS::try_from(os.as_ref());
if opsys.is_err() {
debug!("{}, is not a valid Operating System!", os);
} else {
build_os(&mut targets, opsys.unwrap(), value);
}
}
targets
}
}
impl From<super::EmptyConfig> for Config {
fn from(_: super::EmptyConfig) -> Self {
Config {
release_path: String::new(),
license: String::new(),
readme: String::new(),
config: HashMap::new(),
}
}
}