libimagentryfilter: parameterize Filter by Entry
Signed-off-by: Gavin Thomas Claugus <gclaugus@gmail.com>
This commit is contained in:
parent
0e4079287a
commit
381cec0cca
20 changed files with 31 additions and 31 deletions
|
@ -12,7 +12,7 @@ impl BoolFilter {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for BoolFilter {
|
||||
impl Filter<Entry> for BoolFilter {
|
||||
|
||||
fn filter(&self, _: &Entry) -> bool {
|
||||
self.0
|
||||
|
|
|
@ -43,7 +43,7 @@ impl ContentGrep {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for ContentGrep {
|
||||
impl Filter<Entry> for ContentGrep {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.regex.captures(&e.get_content()[..]).is_some()
|
||||
|
|
|
@ -15,7 +15,7 @@ impl ContentLengthIsOver {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for ContentLengthIsOver {
|
||||
impl Filter<Entry> for ContentLengthIsOver {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.get_content().len() > self.val
|
||||
|
|
|
@ -15,7 +15,7 @@ impl ContentLengthIsUnder {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for ContentLengthIsUnder {
|
||||
impl Filter<Entry> for ContentLengthIsUnder {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.get_content().len() < self.val
|
||||
|
|
|
@ -34,7 +34,7 @@ impl FieldEq {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for FieldEq {
|
||||
impl Filter<Entry> for FieldEq {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.filter.filter(e)
|
||||
|
|
|
@ -17,7 +17,7 @@ impl FieldExists {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for FieldExists {
|
||||
impl Filter<Entry> for FieldExists {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.get_header().read(&self.header_field_path[..]).is_ok()
|
||||
|
|
|
@ -38,7 +38,7 @@ impl FieldGrep {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for FieldGrep {
|
||||
impl Filter<Entry> for FieldGrep {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.filter.filter(e)
|
||||
|
|
|
@ -50,7 +50,7 @@ impl FieldGt {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for FieldGt {
|
||||
impl Filter<Entry> for FieldGt {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.filter.filter(e)
|
||||
|
|
|
@ -19,7 +19,7 @@ impl FieldIsEmpty {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for FieldIsEmpty {
|
||||
impl Filter<Entry> for FieldIsEmpty {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.get_header()
|
||||
|
|
|
@ -59,7 +59,7 @@ impl FieldIsType {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for FieldIsType {
|
||||
impl Filter<Entry> for FieldIsType {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.filter.filter(e)
|
||||
|
|
|
@ -50,7 +50,7 @@ impl FieldLt {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for FieldLt {
|
||||
impl Filter<Entry> for FieldLt {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.filter.filter(e)
|
||||
|
|
|
@ -26,7 +26,7 @@ impl<P: Predicate> FieldPredicate<P> {
|
|||
|
||||
}
|
||||
|
||||
impl<P: Predicate> Filter for FieldPredicate<P> {
|
||||
impl<P: Predicate> Filter<Entry> for FieldPredicate<P> {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.get_header()
|
||||
|
|
|
@ -17,7 +17,7 @@ impl VersionEq {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for VersionEq {
|
||||
impl Filter<Entry> for VersionEq {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.get_header()
|
||||
|
|
|
@ -17,7 +17,7 @@ impl VersionGt {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for VersionGt {
|
||||
impl Filter<Entry> for VersionGt {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.get_header()
|
||||
|
|
|
@ -17,7 +17,7 @@ impl VersionLt {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for VersionLt {
|
||||
impl Filter<Entry> for VersionLt {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.get_header()
|
||||
|
|
|
@ -20,7 +20,7 @@ impl VersionInRange {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for VersionInRange {
|
||||
impl Filter<Entry> for VersionInRange {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.and.filter(e)
|
||||
|
@ -40,7 +40,7 @@ impl VersionOutOfRange {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for VersionOutOfRange {
|
||||
impl Filter<Entry> for VersionOutOfRange {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.not.filter(e)
|
||||
|
|
|
@ -3,19 +3,19 @@ use libimagstore::store::Entry;
|
|||
use filters::filter::Filter;
|
||||
|
||||
pub struct And {
|
||||
a: Box<Filter>,
|
||||
b: Box<Filter>
|
||||
a: Box<Filter<Entry>>,
|
||||
b: Box<Filter<Entry>>
|
||||
}
|
||||
|
||||
impl And {
|
||||
|
||||
pub fn new(a: Box<Filter>, b: Box<Filter>) -> And {
|
||||
pub fn new(a: Box<Filter<Entry>>, b: Box<Filter<Entry>>) -> And {
|
||||
And { a: a, b: b }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Filter for And {
|
||||
impl Filter<Entry> for And {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.a.filter(e) && self.b.filter(e)
|
||||
|
|
|
@ -3,18 +3,18 @@ use libimagstore::store::Entry;
|
|||
use filters::filter::Filter;
|
||||
|
||||
pub struct Not {
|
||||
a: Box<Filter>
|
||||
a: Box<Filter<Entry>>
|
||||
}
|
||||
|
||||
impl Not {
|
||||
|
||||
pub fn new(a: Box<Filter>) -> Not {
|
||||
pub fn new(a: Box<Filter<Entry>>) -> Not {
|
||||
Not { a: a }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Filter for Not {
|
||||
impl Filter<Entry> for Not {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
!self.a.filter(e)
|
||||
|
|
|
@ -3,19 +3,19 @@ use libimagstore::store::Entry;
|
|||
use filters::filter::Filter;
|
||||
|
||||
pub struct Or {
|
||||
a: Box<Filter>,
|
||||
b: Box<Filter>
|
||||
a: Box<Filter<Entry>>,
|
||||
b: Box<Filter<Entry>>
|
||||
}
|
||||
|
||||
impl Or {
|
||||
|
||||
pub fn new(a: Box<Filter>, b: Box<Filter>) -> Or {
|
||||
pub fn new(a: Box<Filter<Entry>>, b: Box<Filter<Entry>>) -> Or {
|
||||
Or { a: a, b: b }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl Filter for Or {
|
||||
impl Filter<Entry> for Or {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.a.filter(e) || self.b.filter(e)
|
||||
|
|
|
@ -19,7 +19,7 @@ impl HasTag {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for HasTag {
|
||||
impl Filter<Entry> for HasTag {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.has_tag(&self.tag).ok().unwrap_or(false)
|
||||
|
@ -43,7 +43,7 @@ impl HasAllTags {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for HasAllTags {
|
||||
impl Filter<Entry> for HasAllTags {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
e.has_tags(&self.tags).ok().unwrap_or(false)
|
||||
|
@ -67,7 +67,7 @@ impl HasAnyTags {
|
|||
|
||||
}
|
||||
|
||||
impl Filter for HasAnyTags {
|
||||
impl Filter<Entry> for HasAnyTags {
|
||||
|
||||
fn filter(&self, e: &Entry) -> bool {
|
||||
self.tags.iter().any(|tag| e.has_tag(tag).ok().unwrap_or(false))
|
||||
|
|
Loading…
Reference in a new issue