Added a function
This commit is contained in:
parent
3d142edf3e
commit
94b3bb27ba
2 changed files with 15 additions and 0 deletions
|
@ -134,6 +134,14 @@ impl CachedCalendar {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The non-async version of [`Self::get_items_mut`]
|
||||||
|
pub fn get_items_mut_sync(&mut self) -> Result<HashMap<Url, &mut Item>, Box<dyn Error>> {
|
||||||
|
Ok(self.items.iter_mut()
|
||||||
|
.map(|(url, item)| (url.clone(), item))
|
||||||
|
.collect()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/// The non-async version of [`Self::get_item_by_url`]
|
/// 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> {
|
pub fn get_item_by_url_sync<'a>(&'a self, url: &Url) -> Option<&'a Item> {
|
||||||
self.items.get(url)
|
self.items.get(url)
|
||||||
|
@ -253,6 +261,10 @@ impl CompleteCalendar for CachedCalendar {
|
||||||
self.get_items_sync()
|
self.get_items_sync()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_items_mut(&mut self) -> Result<HashMap<Url, &mut Item>, Box<dyn Error>> {
|
||||||
|
self.get_items_mut_sync()
|
||||||
|
}
|
||||||
|
|
||||||
async fn get_item_by_url<'a>(&'a self, url: &Url) -> Option<&'a Item> {
|
async fn get_item_by_url<'a>(&'a self, url: &Url) -> Option<&'a Item> {
|
||||||
self.get_item_by_url_sync(url)
|
self.get_item_by_url_sync(url)
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,9 @@ pub trait CompleteCalendar : BaseCalendar {
|
||||||
/// Returns all items that this calendar contains
|
/// Returns all items that this calendar contains
|
||||||
async fn get_items(&self) -> Result<HashMap<Url, &Item>, Box<dyn Error>>;
|
async fn get_items(&self) -> Result<HashMap<Url, &Item>, Box<dyn Error>>;
|
||||||
|
|
||||||
|
/// Returns all items that this calendar contains
|
||||||
|
async fn get_items_mut(&mut self) -> Result<HashMap<Url, &mut Item>, Box<dyn Error>>;
|
||||||
|
|
||||||
/// Returns a particular item
|
/// Returns a particular item
|
||||||
async fn get_item_by_url<'a>(&'a self, url: &Url) -> Option<&'a Item>;
|
async fn get_item_by_url<'a>(&'a self, url: &Url) -> Option<&'a Item>;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue