diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-10-03 12:54:11 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-10-09 19:44:08 +0200 |
commit | b40a854c6f50761c74655d2e7da2655aed581185 (patch) | |
tree | cffa83a4d2afc41c77898eaded1e884e33825cdd /lib/domain/libimagcalendar | |
parent | e86f36c215a43e7f0415e79eb9227adf56769d3e (diff) |
Add function to get all events
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'lib/domain/libimagcalendar')
-rw-r--r-- | lib/domain/libimagcalendar/src/store.rs | 12 |
1 files changed, 12 insertions, 0 deletions
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<ID>(&'a self, id: ID) -> Result<Option<FileLockEntry<'a>>> where ID: AsRef<str>; + + /// Get all events + fn all_events(&'a self) -> Result<Entries<'a>>; + } 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<Entries<'a>> { + self.entries().and_then(|es| es.in_collection("calendar")) + } } |