blob: 0bbbb7329956da39dea04e8bd2b62df88829cd84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
use std::fs;
use serde::Deserialize;
use dirs::home_dir;
use std::path::PathBuf;
#[derive(Debug, Deserialize)]
pub struct Config {
pub lat: String,
pub lon: String,
pub exclude: String,
pub appid: String,
pub lang: String,
pub units: String,
pub cache: bool,
pub rain: String,
pub sunny: String,
pub snowy: String,
}
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)?;
let config: Config = toml::from_str(&config_str)?;
Ok(config)
}
}
pub fn handle_config(_config: &Config) -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
pub fn gen_standard_conf() {
// TODO: Implement
}
|