Added functions to the trait

This commit is contained in:
daladim 2021-02-26 17:55:23 +01:00
parent 8ecab2c182
commit 6b1d5635c6
2 changed files with 30 additions and 1 deletions

View file

@ -6,6 +6,7 @@ use std::error::Error;
use serde::{Deserialize, Serialize};
use async_trait::async_trait;
use url::Url;
use crate::traits::CalDavSource;
use crate::Calendar;
@ -88,6 +89,23 @@ impl CalDavSource for Cache {
.collect()
)
}
async fn get_calendar(&self, url: Url) -> Option<&Calendar> {
for cal in &self.data.calendars {
if cal.url() == &url {
return Some(cal);
}
}
return None;
}
async fn get_calendar_mut(&mut self, url: Url) -> Option<&mut Calendar> {
for cal in &mut self.data.calendars {
if cal.url() == &url {
return Some(cal);
}
}
return None;
}
}