Switch db from json to toml

This commit is contained in:
Lennart
2023-09-07 18:45:28 +02:00
parent 82f15733fa
commit 4da1507919
3 changed files with 13 additions and 13 deletions

View File

@@ -49,15 +49,15 @@ pub trait CalendarStore: Send + Sync + 'static {
}
#[derive(Debug, Deserialize, Serialize)]
pub struct JsonCalendarStore {
pub struct TomlCalendarStore {
calendars: HashMap<String, Calendar>,
events: HashMap<String, Event>,
events: HashMap<String, HashMap<String, Event>>,
path: String,
}
impl JsonCalendarStore {
impl TomlCalendarStore {
pub fn new(path: String) -> Self {
JsonCalendarStore {
TomlCalendarStore {
calendars: HashMap::new(),
events: HashMap::new(),
path,
@@ -66,8 +66,8 @@ impl JsonCalendarStore {
pub async fn save(&self) -> Result<()> {
let mut file = File::create(&self.path).await?;
let json = serde_json::to_string_pretty(&self)?;
file.write_all(json.as_bytes()).await?;
let output = toml::to_string_pretty(&self)?;
file.write_all(output.as_bytes()).await?;
Ok(())
}
}