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