mirror of
https://github.com/csehviktor/status-monitor.git
synced 2025-08-08 18:06:14 +02:00
28 lines
567 B
Rust
28 lines
567 B
Rust
use rumqttd::Config;
|
|
use serde::Deserialize;
|
|
|
|
const CONFIG_PATH: &str = if cfg!(debug_assertions) {
|
|
"server/config.toml"
|
|
} else {
|
|
"config.toml"
|
|
};
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct StorageConfig {
|
|
pub sqlite: bool,
|
|
pub db_path: String,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct Configuration {
|
|
pub storage: StorageConfig,
|
|
pub mqtt: Config,
|
|
}
|
|
|
|
pub fn load_config() -> anyhow::Result<Configuration> {
|
|
let content = std::fs::read_to_string(CONFIG_PATH)?;
|
|
let config: Configuration = toml::from_str(&content)?;
|
|
|
|
Ok(config)
|
|
}
|