Refactor libimagentrycategory to fit new store iterator interface
This commit is contained in:
parent
6f81d02445
commit
6ee3f4a3f6
2 changed files with 35 additions and 25 deletions
|
@ -55,7 +55,7 @@ impl Category for Entry {
|
||||||
|
|
||||||
fn get_entries<'a>(&self, store: &'a Store) -> Result<CategoryEntryIterator<'a>> {
|
fn get_entries<'a>(&self, store: &'a Store) -> Result<CategoryEntryIterator<'a>> {
|
||||||
trace!("Getting linked entries for category '{:?}'", self.get_location());
|
trace!("Getting linked entries for category '{:?}'", self.get_location());
|
||||||
let sit = self.get_internal_links()?.map(|l| l.get_store_id().clone());
|
let sit = self.get_internal_links()?.map(|l| l.get_store_id().clone()).map(Ok);
|
||||||
let sit = StoreIdIterator::new(Box::new(sit));
|
let sit = StoreIdIterator::new(Box::new(sit));
|
||||||
let name = self.get_name()?;
|
let name = self.get_name()?;
|
||||||
Ok(CategoryEntryIterator::new(store, sit, name))
|
Ok(CategoryEntryIterator::new(store, sit, name))
|
||||||
|
|
|
@ -60,6 +60,9 @@ impl<'a> Iterator for CategoryNameIter<'a> {
|
||||||
let query = CATEGORY_REGISTER_NAME_FIELD_PATH;
|
let query = CATEGORY_REGISTER_NAME_FIELD_PATH;
|
||||||
|
|
||||||
while let Some(sid) = self.1.next() {
|
while let Some(sid) = self.1.next() {
|
||||||
|
match sid {
|
||||||
|
Err(e) => return Some(Err(e).map_err(CE::from)),
|
||||||
|
Ok(sid) => {
|
||||||
if sid.is_in_collection(&["category"]) {
|
if sid.is_in_collection(&["category"]) {
|
||||||
let func = |store: &Store| { // hack for returning Some(Result<_, _>)
|
let func = |store: &Store| { // hack for returning Some(Result<_, _>)
|
||||||
store
|
store
|
||||||
|
@ -72,6 +75,8 @@ impl<'a> Iterator for CategoryNameIter<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
return Some(func(&self.0))
|
return Some(func(&self.0))
|
||||||
|
}
|
||||||
|
},
|
||||||
} // else continue
|
} // else continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +97,9 @@ impl<'a> Iterator for CategoryEntryIterator<'a> {
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
while let Some(next) = self.1.next() {
|
while let Some(next) = self.1.next() {
|
||||||
|
match next {
|
||||||
|
Err(e) => return Some(Err(e).map_err(CE::from)),
|
||||||
|
Ok(next) => {
|
||||||
let getter = |next| -> Result<(String, FileLockEntry<'a>)> {
|
let getter = |next| -> Result<(String, FileLockEntry<'a>)> {
|
||||||
let entry = self.0
|
let entry = self.0
|
||||||
.get(next)?
|
.get(next)?
|
||||||
|
@ -110,6 +118,8 @@ impl<'a> Iterator for CategoryEntryIterator<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue