StorageBackend::iter_ids() return Result<> with StorageBackendError on error
This commit is contained in:
parent
d4cb51486b
commit
3df106ce8b
1 changed files with 16 additions and 8 deletions
|
@ -72,15 +72,23 @@ impl StorageBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_ids(&self, m: &Module) -> Option<IntoIter<FileID>>
|
pub fn iter_ids(&self, m: &Module) -> Result<IntoIter<FileID>, StorageBackendError>
|
||||||
{
|
{
|
||||||
glob(&self.prefix_of_files_for_module(m)[..]).and_then(|globlist| {
|
glob(&self.prefix_of_files_for_module(m)[..])
|
||||||
let v = globlist.filter_map(Result::ok)
|
.and_then(|globlist| {
|
||||||
.map(|pbuf| FileID::from(&pbuf))
|
let v = globlist.filter_map(Result::ok)
|
||||||
.collect::<Vec<FileID>>()
|
.map(|pbuf| FileID::from(&pbuf))
|
||||||
.into_iter();
|
.collect::<Vec<FileID>>()
|
||||||
Ok(v)
|
.into_iter();
|
||||||
}).ok()
|
Ok(v)
|
||||||
|
})
|
||||||
|
.map_err(|e| {
|
||||||
|
let serr = StorageBackendError::build(
|
||||||
|
"iter_ids()",
|
||||||
|
"Cannot iter on file ids",
|
||||||
|
None);
|
||||||
|
serr
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter_files<'a, HP>(&self, m: &'a Module, p: &Parser<HP>)
|
pub fn iter_files<'a, HP>(&self, m: &'a Module, p: &Parser<HP>)
|
||||||
|
|
Loading…
Reference in a new issue