Rewrite all_category_names() for removed Store::retrieve_for_module()
This commit is contained in:
parent
255f4211c9
commit
007c02c2f1
1 changed files with 19 additions and 15 deletions
|
@ -101,9 +101,7 @@ impl CategoryRegister for Store {
|
|||
|
||||
/// Get all category names
|
||||
fn all_category_names(&self) -> Result<CategoryNameIter> {
|
||||
self.retrieve_for_module("category")
|
||||
.chain_err(|| CEK::StoreReadError)
|
||||
.map(|iter| CategoryNameIter::new(self, iter))
|
||||
Ok(CategoryNameIter::new(self, self.entries()?.without_store()))
|
||||
}
|
||||
|
||||
/// Get a category by its name
|
||||
|
@ -268,10 +266,10 @@ impl<'a> Iterator for CategoryNameIter<'a> {
|
|||
// TODO: Optimize me with lazy_static
|
||||
let query = CATEGORY_REGISTER_NAME_FIELD_PATH;
|
||||
|
||||
self.1
|
||||
.next()
|
||||
.map(|sid| {
|
||||
self.0
|
||||
while let Some(sid) = self.1.next() {
|
||||
if sid.is_in_collection(&["category"]) {
|
||||
let func = |store: &Store| { // hack for returning Some(Result<_, _>)
|
||||
store
|
||||
.get(sid)?
|
||||
.ok_or_else(|| CE::from_kind(CEK::StoreReadError))?
|
||||
.get_header()
|
||||
|
@ -279,7 +277,13 @@ impl<'a> Iterator for CategoryNameIter<'a> {
|
|||
.chain_err(|| CEK::HeaderReadError)?
|
||||
.map(Category::from)
|
||||
.ok_or_else(|| CE::from_kind(CEK::StoreReadError))
|
||||
})
|
||||
};
|
||||
|
||||
return Some(func(&self.0))
|
||||
} // else continue
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue