Add builtin content filter: length filtering
This commit is contained in:
parent
f81190fb8a
commit
a00092c8be
4 changed files with 59 additions and 0 deletions
28
libimagentryfilter/src/builtin/content/length/is_over.rs
Normal file
28
libimagentryfilter/src/builtin/content/length/is_over.rs
Normal 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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
28
libimagentryfilter/src/builtin/content/length/is_under.rs
Normal file
28
libimagentryfilter/src/builtin/content/length/is_under.rs
Normal 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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
2
libimagentryfilter/src/builtin/content/length/mod.rs
Normal file
2
libimagentryfilter/src/builtin/content/length/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
pub mod is_over;
|
||||
pub mod is_under;
|
|
@ -1 +1,2 @@
|
|||
pub mod grep;
|
||||
pub mod length;
|
||||
|
|
Loading…
Reference in a new issue