mirror of
				https://github.com/csehviktor/status-monitor.git
				synced 2025-08-08 18:06:14 +02:00 
			
		
		
		
	cleaup code
This commit is contained in:
		| @@ -1,14 +1,20 @@ | ||||
| use rumqttd::Config; | ||||
| use serde::Deserialize; | ||||
|  | ||||
| const BROKER_CONFIG_PATH: &str = if cfg!(debug_assertions) { | ||||
|     "server/mqtt.toml" | ||||
| const CONFIG_PATH: &str = if cfg!(debug_assertions) { | ||||
|     "server/config.toml" | ||||
| } else { | ||||
|     "mqtt.toml" | ||||
|     "config.toml" | ||||
| }; | ||||
|  | ||||
| pub fn load_broker_config() -> anyhow::Result<Config> { | ||||
|     let content = std::fs::read_to_string(BROKER_CONFIG_PATH)?; | ||||
|     let config: Config = toml::from_str(&content)?; | ||||
| #[derive(Debug, Deserialize)] | ||||
| pub struct Configuration { | ||||
|     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) | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user