25 lines
599 B
Rust
25 lines
599 B
Rust
use serde::Deserialize;
|
|
use config::{Config, ConfigError, File};
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
pub struct SpacecraftConfig {
|
|
pub spacecraft_name: String,
|
|
pub spacecraft_id: u64,
|
|
pub color: (u8, u8, u8)
|
|
}
|
|
|
|
#[derive(Debug, Deserialize, Clone)]
|
|
pub struct VisualizerConfig {
|
|
pub dsn_address: String,
|
|
pub polling_rate: u64,
|
|
pub spacecraft: Vec<SpacecraftConfig>
|
|
}
|
|
|
|
impl VisualizerConfig {
|
|
pub fn new(config_path: &str) -> Result<Self,ConfigError> {
|
|
let mut cfg = Config::new();
|
|
cfg.merge(File::with_name(config_path))?;
|
|
cfg.try_into()
|
|
}
|
|
}
|