StorageBackend::iter_files() return Result<> with StorageBackendError on error
This commit is contained in:
parent
3df106ce8b
commit
be094dcfae
1 changed files with 14 additions and 6 deletions
|
@ -92,14 +92,22 @@ impl StorageBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
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>)
|
||||||
-> Option<IntoIter<File<'a>>>
|
-> Result<IntoIter<File<'a>>, StorageBackendError>
|
||||||
where HP: FileHeaderParser
|
where HP: FileHeaderParser
|
||||||
{
|
{
|
||||||
self.iter_ids(m).and_then(|ids| {
|
self.iter_ids(m)
|
||||||
Some(ids.filter_map(|id| self.get_file_by_id(m, &id, p))
|
.and_then(|ids| {
|
||||||
|
Ok(ids.filter_map(|id| self.get_file_by_id(m, &id, p))
|
||||||
.collect::<Vec<File>>()
|
.collect::<Vec<File>>()
|
||||||
.into_iter())
|
.into_iter())
|
||||||
})
|
})
|
||||||
|
.map_err(|e| {
|
||||||
|
let serr = StorageBackendError::build(
|
||||||
|
"iter_files()",
|
||||||
|
"Cannot iter on files",
|
||||||
|
None);
|
||||||
|
serr
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue