From b40a854c6f50761c74655d2e7da2655aed581185 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 3 Oct 2019 12:54:11 +0200 Subject: [PATCH] Add function to get all events Signed-off-by: Matthias Beyer --- lib/domain/libimagcalendar/src/store.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/domain/libimagcalendar/src/store.rs b/lib/domain/libimagcalendar/src/store.rs index 656100e5..107bdabe 100644 --- a/lib/domain/libimagcalendar/src/store.rs +++ b/lib/domain/libimagcalendar/src/store.rs @@ -31,6 +31,7 @@ use libimagentryref::hasher::default::DefaultHasher; use libimagentryref::reference::RefFassade; use libimagstore::store::FileLockEntry; use libimagstore::store::Store; +use libimagstore::iter::Entries; use crate::event::IsEvent; @@ -61,6 +62,10 @@ pub trait EventStore<'a> { fn get_event_by_uid(&'a self, id: ID) -> Result>> where ID: AsRef; + + /// Get all events + fn all_events(&'a self) -> Result>; + } impl<'a> EventStore<'a> for Store { @@ -103,5 +108,12 @@ impl<'a> EventStore<'a> for Store { { self.get(crate::module_path::new_id(id.as_ref())?) } + + /// Get all events + /// + /// Uses Store::entries(), so there might be false positives. + fn all_events(&'a self) -> Result> { + self.entries().and_then(|es| es.in_collection("calendar")) + } }