StorageBackend::iter_files() return Result<> with StorageBackendError on error

This commit is contained in:
Matthias Beyer 2015-12-04 14:04:20 +01:00
parent 3df106ce8b
commit be094dcfae

View file

@ -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| {
.collect::<Vec<File>>() Ok(ids.filter_map(|id| self.get_file_by_id(m, &id, p))
.into_iter()) .collect::<Vec<File>>()
}) .into_iter())
})
.map_err(|e| {
let serr = StorageBackendError::build(
"iter_files()",
"Cannot iter on files",
None);
serr
})
} }
/* /*