refactor conf
This commit is contained in:
parent
61ede78868
commit
edba874ae7
6 changed files with 69 additions and 37 deletions
32
src/conf.rs
32
src/conf.rs
|
|
@ -1,21 +1,31 @@
|
|||
use config::Config;
|
||||
use serde::Deserialize;
|
||||
use serde::{Serialize,Deserialize};
|
||||
use crate::errors::LJResult;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub enum DacFamily {
|
||||
Helios,
|
||||
Etherdream,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Serialize, 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>,
|
||||
pub dac: DacFamily
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum DacFamily {
|
||||
#[serde(rename = "helios")]
|
||||
Helios(HeliosConf),
|
||||
#[serde(rename = "etherdream")]
|
||||
Etherdream(EtherDreamConf),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HeliosConf {
|
||||
pub id: u8
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct EtherDreamConf {
|
||||
pub url: String
|
||||
}
|
||||
|
||||
impl Conf {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue