0
0
Fork 0
mirror of https://git.verdigado.com/NB-Public/simple-wkd.git synced 2024-10-30 09:05:52 +01:00
simple-wkd/src/settings.rs

48 lines
1.1 KiB
Rust
Raw Normal View History

2023-04-14 00:52:54 +02:00
use std::fs;
use once_cell::sync::Lazy;
use sequoia_net::wkd::Variant;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct Settings {
#[serde(with = "VariantDef")]
pub variant: Variant,
pub max_age: i64,
2023-04-14 01:05:27 +02:00
pub cleanup_interval: u64,
2023-04-14 00:52:54 +02:00
pub port: u16,
pub folder_structure: FolderStructure,
pub smtp_settings: MailSettings,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct FolderStructure {
pub root_folder: String,
pub pending_folder: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct MailSettings {
pub smtp_host: String,
pub smtp_username: String,
pub smtp_password: String,
pub smtp_port: u16,
pub mail_from: String,
pub mail_subject: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(remote = "Variant")]
pub enum VariantDef {
Advanced,
Direct,
}
fn get_settings() -> Settings {
2023-04-14 01:05:27 +02:00
println!("Reaing settings...");
2023-04-14 00:52:54 +02:00
let content = fs::read_to_string("wkd.toml").unwrap();
toml::from_str(&content).unwrap()
}
pub static SETTINGS: Lazy<Settings> = Lazy::new(get_settings);