summaryrefslogtreecommitdiffstats
path: root/libimagnotes
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-05-28 21:26:05 +0200
committerMatthias Beyer <mail@beyermatthias.de>2016-05-28 21:26:05 +0200
commit8caeb17729835059c003161379e5295359154ef7 (patch)
tree45419ecd86d6707c9fa9409b9ff9f4e3bdc85b74 /libimagnotes
parent59152e6a52ce742142c3fbee8386a517402c56a2 (diff)
Add Note::get()
Diffstat (limited to 'libimagnotes')
-rw-r--r--libimagnotes/src/note.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/libimagnotes/src/note.rs b/libimagnotes/src/note.rs
index bf1c0095..fc0a507d 100644
--- a/libimagnotes/src/note.rs
+++ b/libimagnotes/src/note.rs
@@ -102,6 +102,16 @@ impl<'a> Note<'a> {
.map(|entry| Note { entry: entry })
}
+ pub fn get(store: &Store, name: String) -> Result<Option<Note>> {
+ use libimagerror::into::IntoError;
+
+ match store.get(ModuleEntryPath::new(name).into_storeid()) {
+ Ok(Some(entry)) => Ok(Some(Note { entry: entry })),
+ Ok(None) => Ok(None),
+ Err(e) => Err(NEK::StoreWriteError.into_error_with_cause(Box::new(e))),
+ }
+ }
+
pub fn all_notes(store: &Store) -> Result<NoteIterator> {
store.retrieve_for_module("notes")
.map(|iter| NoteIterator::new(store, iter))