diff --git a/libimagentryfilter/src/builtin/header/field_exists.rs b/libimagentryfilter/src/builtin/header/field_exists.rs new file mode 100644 index 00000000..45bc870a --- /dev/null +++ b/libimagentryfilter/src/builtin/header/field_exists.rs @@ -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() + } + +} + + diff --git a/libimagentryfilter/src/builtin/header/mod.rs b/libimagentryfilter/src/builtin/header/mod.rs index 1dd2cb69..886e5ce6 100644 --- a/libimagentryfilter/src/builtin/header/mod.rs +++ b/libimagentryfilter/src/builtin/header/mod.rs @@ -1,5 +1,6 @@ pub mod field_eq; +pub mod field_exists; pub mod field_grep; +pub mod field_isempty; pub mod field_istype; pub mod field_path; -