Add builtin content filter: length filtering

This commit is contained in:
Matthias Beyer 2016-02-03 16:37:48 +01:00
parent f81190fb8a
commit a00092c8be
4 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,28 @@
use libimagstore::store::Entry;
use builtin::header::field_path::FieldPath;
use filter::Filter;
pub struct ContentLengthIsOver {
val: usize
}
impl ContentLengthIsOver {
pub fn new(value: usize) -> ContentLengthIsOver {
ContentLengthIsOver {
val: value,
}
}
}
impl Filter for ContentLengthIsOver {
fn filter(&self, e: &Entry) -> bool {
e.get_content().len() > self.val
}
}

View file

@ -0,0 +1,28 @@
use libimagstore::store::Entry;
use builtin::header::field_path::FieldPath;
use filter::Filter;
pub struct ContentLengthIsUnder {
val: usize
}
impl ContentLengthIsUnder {
pub fn new(value: usize) -> ContentLengthIsUnder {
ContentLengthIsUnder {
val: value,
}
}
}
impl Filter for ContentLengthIsUnder {
fn filter(&self, e: &Entry) -> bool {
e.get_content().len() < self.val
}
}

View file

@ -0,0 +1,2 @@
pub mod is_over;
pub mod is_under;

View file

@ -1 +1,2 @@
pub mod grep;
pub mod length;