Merge pull request #496 from matthiasbeyer/libimagentrylist/generic-core
libimagentrylist: Make CoreLister generic
This commit is contained in:
commit
1211a99775
2 changed files with 8 additions and 7 deletions
|
@ -7,6 +7,7 @@ use libimagdiary::error::DiaryErrorKind as DEK;
|
||||||
use libimagentrylist::listers::core::CoreLister;
|
use libimagentrylist::listers::core::CoreLister;
|
||||||
use libimagentrylist::lister::Lister;
|
use libimagentrylist::lister::Lister;
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
|
use libimagstore::store::Entry;
|
||||||
use libimagstore::storeid::StoreId;
|
use libimagstore::storeid::StoreId;
|
||||||
use libimagerror::trace::trace_error;
|
use libimagerror::trace::trace_error;
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ pub fn list(rt: &Runtime) {
|
||||||
|
|
||||||
let base = rt.store().path();
|
let base = rt.store().path();
|
||||||
|
|
||||||
CoreLister::new(&move |e| location_to_listing_string(e.get_location(), base))
|
CoreLister::new(&move |e: &Entry| location_to_listing_string(e.get_location(), base))
|
||||||
.list(es) // TODO: Do not ignore non-ok()s
|
.list(es) // TODO: Do not ignore non-ok()s
|
||||||
.map_err(|e| DE::new(DEK::IOError, Some(Box::new(e))))
|
.map_err(|e| DE::new(DEK::IOError, Some(Box::new(e))))
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,21 +7,21 @@ use result::Result;
|
||||||
use libimagstore::store::FileLockEntry;
|
use libimagstore::store::FileLockEntry;
|
||||||
use libimagstore::store::Entry;
|
use libimagstore::store::Entry;
|
||||||
|
|
||||||
pub struct CoreLister<'a> {
|
pub struct CoreLister<T: Fn(&Entry) -> String> {
|
||||||
lister: &'a Fn(&Entry) -> String,
|
lister: Box<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CoreLister<'a> {
|
impl<T: Fn(&Entry) -> String> CoreLister<T> {
|
||||||
|
|
||||||
pub fn new(lister: &'a Fn(&Entry) -> String) -> CoreLister<'a> {
|
pub fn new(lister: T) -> CoreLister<T> {
|
||||||
CoreLister {
|
CoreLister {
|
||||||
lister: lister,
|
lister: Box::new(lister),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Lister for CoreLister<'a> {
|
impl<T: Fn(&Entry) -> String> Lister for CoreLister<T> {
|
||||||
|
|
||||||
fn list<'b, I: Iterator<Item = FileLockEntry<'b>>>(&self, entries: I) -> Result<()> {
|
fn list<'b, I: Iterator<Item = FileLockEntry<'b>>>(&self, entries: I) -> Result<()> {
|
||||||
use error::ListError as LE;
|
use error::ListError as LE;
|
||||||
|
|
Loading…
Reference in a new issue