diff options
| author | Namilskyy <alive6863@gmail.com> | 2025-10-21 18:11:49 +0300 |
|---|---|---|
| committer | Namilskyy <alive6863@gmail.com> | 2025-10-21 18:11:49 +0300 |
| commit | 26092b2043649a466d07fbb87078adc8c8612621 (patch) | |
| tree | 965a76cb59a9f6afba7c7f4f8a48cd599d698ddb /src/configmanager.rs | |
| parent | 1ad9fda27ca8757dfc6a3d4ee0f43232146b7f98 (diff) | |
Started refactoring bad code. Edited: `parser.rs`, `main.rs`, switched weather-structs to `shared.rs`
Diffstat (limited to 'src/configmanager.rs')
| -rw-r--r-- | src/configmanager.rs | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/configmanager.rs b/src/configmanager.rs deleted file mode 100644 index c005d2c..0000000 --- a/src/configmanager.rs +++ /dev/null @@ -1,46 +0,0 @@ -use std::fs; -use serde::Deserialize; -use dirs::home_dir; - -#[derive(Debug, Deserialize, Clone)] -pub struct Config { - pub lat: f64, - pub lon: f64, - pub exclude: String, - pub appid: String, - pub lang: String, - pub units: String, - pub cache: bool, - pub rain: String, - pub sunny: String, - pub snowy: String, -} - -type BoxedError = Box<dyn std::error::Error + Send + Sync>; - - - -pub fn handle_config(_config: &Config) -> Result<(), Box<dyn std::error::Error>> { - Ok(()) -} - -pub fn gen_standard_conf() { - // TODO: Implement -} - -impl Config { - pub fn load() -> Result<Self, Box<dyn std::error::Error>> { - let mut path = home_dir().ok_or("Home directory not found")?; - path.push(".config/WeatherFetch/Config.toml"); - - let config_str = fs::read_to_string(&path) - .map_err(|e| format!("Failed to read config: {}", e))?; - - let config: Config = toml::from_str(&config_str) - .map_err(|e| format!("Invalid TOML: {}", e))?; - - Ok(config) - } -} - - |
