From 707d764e6be0c741457bfcf5a0cfb043d3b5e303 Mon Sep 17 00:00:00 2001 From: daladim Date: Fri, 2 Apr 2021 09:35:45 +0200 Subject: [PATCH] Implemented get_item_by_id for CachedCalendar --- src/calendar/cached_calendar.rs | 4 ++++ src/traits.rs | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/calendar/cached_calendar.rs b/src/calendar/cached_calendar.rs index 9b4d405..9e09fac 100644 --- a/src/calendar/cached_calendar.rs +++ b/src/calendar/cached_calendar.rs @@ -137,6 +137,10 @@ impl DavCalendar for CachedCalendar { Ok(result) } + async fn get_item_by_id(&self, id: &ItemId) -> Result, Box> { + Ok(self.items.get(id).cloned()) + } + async fn delete_item(&mut self, item_id: &ItemId) -> Result<(), Box> { self.immediately_delete_item(item_id).await } diff --git a/src/traits.rs b/src/traits.rs index c558a59..74859b2 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -54,6 +54,9 @@ pub trait DavCalendar : BaseCalendar { /// Get the IDs and the version tags of every item in this calendar async fn get_item_version_tags(&self) -> Result, Box>; + /// Returns a particular item + async fn get_item_by_id(&self, id: &ItemId) -> Result, Box>; + /// Delete an item async fn delete_item(&mut self, item_id: &ItemId) -> Result<(), Box>; @@ -64,9 +67,6 @@ pub trait DavCalendar : BaseCalendar { .map(|(id, _tag)| id.clone()) .collect()) } - - /// Returns a particular item - async fn get_item_by_id(&self, id: &ItemId) -> Result, Box>; }