use std::io::Read; use std::path::PathBuf; use std::fs::File; use toml; use serde_derive::Deserialize; #[derive(Deserialize)] pub struct Config { from: String, to: Vec, branches: Vec, git: Git, schedule: Schedule } #[derive(Deserialize)] struct Git { ssh_identity_file: String, } #[derive(Deserialize)] struct Schedule { enabled: bool, duration: i32, } pub fn read_config(paths: Vec) -> Vec { let mut configs: Vec = vec![]; for path in paths { let mut data = String::new(); let mut file = match File::open(path.as_path()) { Err(e) => panic!("unable to open {}: {}", path.as_path().display(), e), Ok(file) => file }; if let Err(e) = file.read_to_string(&mut data) { panic!("unable to read {}: {}", path.as_path().display(), e) } configs.push(verify_config(toml::from_str(&data).unwrap())); } return configs; } fn verify_config(config: Config) -> Config { return config; }