Add Viewer Trait
This commit is contained in:
parent
2a61af2a9d
commit
b388c6684e
1 changed files with 17 additions and 0 deletions
17
libimagentryview/src/viewer.rs
Normal file
17
libimagentryview/src/viewer.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use libimagstore::store::Entry;
|
||||
|
||||
use result::Result;
|
||||
|
||||
pub trait Viewer {
|
||||
|
||||
fn view_entry(&self, e: &Entry) -> Result<()>;
|
||||
|
||||
fn view_entries<I: Iterator<Item = Entry>>(&self, entries: I) -> Result<()> {
|
||||
for entry in entries {
|
||||
if let Err(e) = self.view_entry(&entry) {
|
||||
return Err(e);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue