lj_rust/src/conf.rs
2023-06-03 18:54:41 +02:00

29 lines
569 B
Rust

use config::Config;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub enum DacFamily {
Helios,
Etherdream,
}
#[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 fn load_config(path: &str) -> Result<Conf, Box<dyn std::error::Error>> {
let settings = Config::builder()
.add_source(config::File::with_name(path))
.build()?;
let conf = settings.try_deserialize::<Conf>()?;
Ok(conf)
}