diff --git a/src/calendar/cached_calendar.rs b/src/calendar/cached_calendar.rs index 502cdbd..af495bb 100644 --- a/src/calendar/cached_calendar.rs +++ b/src/calendar/cached_calendar.rs @@ -134,6 +134,14 @@ impl CachedCalendar { ) } + /// The non-async version of [`Self::get_items_mut`] + pub fn get_items_mut_sync(&mut self) -> Result, Box> { + Ok(self.items.iter_mut() + .map(|(url, item)| (url.clone(), item)) + .collect() + ) + } + /// The non-async version of [`Self::get_item_by_url`] pub fn get_item_by_url_sync<'a>(&'a self, url: &Url) -> Option<&'a Item> { self.items.get(url) @@ -253,6 +261,10 @@ impl CompleteCalendar for CachedCalendar { self.get_items_sync() } + async fn get_items_mut(&mut self) -> Result, Box> { + self.get_items_mut_sync() + } + async fn get_item_by_url<'a>(&'a self, url: &Url) -> Option<&'a Item> { self.get_item_by_url_sync(url) } diff --git a/src/traits.rs b/src/traits.rs index e6d5f28..c707e50 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -115,6 +115,9 @@ pub trait CompleteCalendar : BaseCalendar { /// Returns all items that this calendar contains async fn get_items(&self) -> Result, Box>; + /// Returns all items that this calendar contains + async fn get_items_mut(&mut self) -> Result, Box>; + /// Returns a particular item async fn get_item_by_url<'a>(&'a self, url: &Url) -> Option<&'a Item>;