Add builtin header check: Field exists
This commit is contained in:
parent
12443f631b
commit
780410f29d
2 changed files with 33 additions and 1 deletions
31
libimagentryfilter/src/builtin/header/field_exists.rs
Normal file
31
libimagentryfilter/src/builtin/header/field_exists.rs
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
use libimagstore::store::Entry;
|
||||||
|
|
||||||
|
use builtin::header::field_path::FieldPath;
|
||||||
|
use filter::Filter;
|
||||||
|
|
||||||
|
use toml::Value;
|
||||||
|
|
||||||
|
pub struct FieldExists {
|
||||||
|
header_field_path: FieldPath,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FieldExists {
|
||||||
|
|
||||||
|
pub fn new(path: FieldPath) -> FieldExists {
|
||||||
|
FieldExists {
|
||||||
|
header_field_path: path,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Filter for FieldExists {
|
||||||
|
|
||||||
|
fn filter(&self, e: &Entry) -> bool {
|
||||||
|
let header = e.get_header();
|
||||||
|
self.header_field_path.walk(header).is_some()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
pub mod field_eq;
|
pub mod field_eq;
|
||||||
|
pub mod field_exists;
|
||||||
pub mod field_grep;
|
pub mod field_grep;
|
||||||
|
pub mod field_isempty;
|
||||||
pub mod field_istype;
|
pub mod field_istype;
|
||||||
pub mod field_path;
|
pub mod field_path;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue