29 lines
700 B
Rust
29 lines
700 B
Rust
use std::fs::read_to_string;
|
|
use std::collections::BTreeMap;
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
pub struct CalendarOptions {
|
|
pub url: String,
|
|
pub color: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
|
pub struct Config {
|
|
pub db_url: String,
|
|
pub calendars: BTreeMap<String, CalendarOptions>,
|
|
pub weekdays: Vec<String>,
|
|
pub months: Vec<String>,
|
|
pub upcoming_days: u32,
|
|
}
|
|
|
|
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")
|
|
}
|
|
}
|