summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-04-30 17:28:54 +0200
committerMatthias Beyer <mail@beyermatthias.de>2018-05-01 17:44:01 +0200
commit6f81d0244572ef811d3819f7ca63f55f566f9ed1 (patch)
tree0c6cdef1f2b9a5f3c0c450db793c0a4d3aed4960 /lib
parent40688a3c2da8054f144b915f7676fba0e802c30c (diff)
Refactor libimagentryannotation to fit new store iterator interface
Diffstat (limited to 'lib')
-rw-r--r--lib/entry/libimagentryannotation/src/annotateable.rs2
-rw-r--r--lib/entry/libimagentryannotation/src/iter.rs28
2 files changed, 17 insertions, 13 deletions
diff --git a/lib/entry/libimagentryannotation/src/annotateable.rs b/lib/entry/libimagentryannotation/src/annotateable.rs
index 4906b174..d38b9c66 100644
--- a/lib/entry/libimagentryannotation/src/annotateable.rs
+++ b/lib/entry/libimagentryannotation/src/annotateable.rs
@@ -92,7 +92,7 @@ impl Annotateable for Entry {
fn annotations<'a>(&self, store: &'a Store) -> Result<AnnotationIter<'a>> {
self.get_internal_links()
.map_err(From::from)
- .map(|iter| StoreIdIterator::new(Box::new(iter.map(|e| e.get_store_id().clone()))))
+ .map(|iter| StoreIdIterator::new(Box::new(iter.map(|e| e.get_store_id().clone()).map(Ok))))
.map(|i| AnnotationIter::new(i, store))
}
diff --git a/lib/entry/libimagentryannotation/src/iter.rs b/lib/entry/libimagentryannotation/src/iter.rs
index 996c6ffd..9485ba07 100644
--- a/lib/entry/libimagentryannotation/src/iter.rs
+++ b/lib/entry/libimagentryannotation/src/iter.rs
@@ -24,6 +24,7 @@ use libimagstore::store::FileLockEntry;
use libimagstore::storeid::StoreIdIterator;
use error::Result;
+use error::AnnotationError as AE;
use error::AnnotationErrorKind as AEK;
use error::ResultExt;
@@ -43,18 +44,21 @@ impl<'a> Iterator for AnnotationIter<'a> {
fn next(&mut self) -> Option<Self::Item> {
loop {
- match self.0.next().map(|id| self.1.get(id)) {
- Some(Ok(Some(entry))) => {
- match entry.get_header().read_bool("annotation.is_annotation").chain_err(|| AEK::HeaderReadError) {
- Ok(None) => continue, // not an annotation
- Ok(Some(false)) => continue,
- Ok(Some(true)) => return Some(Ok(entry)),
- Err(e) => return Some(Err(e)),
- }
- },
- Some(Ok(None)) => continue,
- Some(Err(e)) => return Some(Err(e).chain_err(|| AEK::StoreReadError)),
- None => return None, // iterator consumed
+ match self.0.next() {
+ None => return None, // iterator consumed
+ Some(Err(e)) => return Some(Err(e).map_err(AE::from)),
+ Some(Ok(id)) => match self.1.get(id) {
+ Err(e) => return Some(Err(e).chain_err(|| AEK::StoreReadError)),
+ Ok(Some(entry)) => {
+ match entry.get_header().read_bool("annotation.is_annotation").chain_err(|| AEK::HeaderReadError) {
+ Ok(None) => continue, // not an annotation
+ Ok(Some(false)) => continue,
+ Ok(Some(true)) => return Some(Ok(entry)),
+ Err(e) => return Some(Err(e)),
+ }
+ },
+ Ok(None) => continue,
+ }
}
}
}