feat: add tests for conf
This commit is contained in:
parent
ae14cb600d
commit
312a48ff5b
4 changed files with 56 additions and 11 deletions
14
src/conf.rs
14
src/conf.rs
|
|
@ -9,14 +9,13 @@ pub enum DacFamily {
|
|||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Conf {
|
||||
laser_id: u8,
|
||||
debug: bool,
|
||||
redis_url: String,
|
||||
dac_family: DacFamily,
|
||||
dac_id: Option<u8>,
|
||||
dac_url: Option<String>,
|
||||
pub laser_id: u8,
|
||||
pub debug: bool,
|
||||
pub redis_url: String,
|
||||
pub dac_family: DacFamily,
|
||||
pub dac_id: Option<u8>,
|
||||
pub dac_url: Option<String>,
|
||||
}
|
||||
|
||||
pub fn load_config(path: &str) -> Result<Conf, Box<dyn std::error::Error>> {
|
||||
let settings = Config::builder()
|
||||
.add_source(config::File::with_name(path))
|
||||
|
|
@ -24,5 +23,6 @@ pub fn load_config(path: &str) -> Result<Conf, Box<dyn std::error::Error>> {
|
|||
|
||||
let conf = settings.try_deserialize::<Conf>()?;
|
||||
|
||||
|
||||
Ok(conf)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue