2019-10-26 01:14:49 +02:00
|
|
|
use std::fs::read_to_string;
|
2019-10-10 02:37:24 +02:00
|
|
|
use std::collections::BTreeMap;
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
|
|
|
|
|
2020-10-26 19:48:17 +01:00
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
2019-10-10 02:37:24 +02:00
|
|
|
pub struct CalendarOptions {
|
|
|
|
pub url: String,
|
2020-10-26 19:48:17 +01:00
|
|
|
pub color: String,
|
2019-10-10 02:37:24 +02:00
|
|
|
}
|
|
|
|
|
2020-10-26 19:48:17 +01:00
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
2019-10-10 02:37:24 +02:00
|
|
|
pub struct Config {
|
|
|
|
pub db_url: String,
|
|
|
|
pub calendars: BTreeMap<String, CalendarOptions>,
|
2020-10-26 19:48:17 +01:00
|
|
|
pub weekdays: Vec<String>,
|
|
|
|
pub months: Vec<String>,
|
2019-10-10 02:37:24 +02:00
|
|
|
}
|
2019-10-26 01:14:49 +02:00
|
|
|
|
|
|
|
impl Config {
|
|
|
|
pub fn read_yaml_file(path: &str) -> Self {
|
|
|
|
let config_file = read_to_string(path)
|
|
|
|
.expect(path);
|
|
|
|
serde_yaml::from_str(&config_file)
|
|
|
|
.expect("config")
|
|
|
|
}
|
|
|
|
}
|