diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2016-02-03 16:23:39 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2016-02-07 01:44:42 +0100 |
commit | 780410f29dd2e1bd91b3c75502b3916013e2252e (patch) | |
tree | d34bc9a597277586a590dea8afb614d52a5c8035 /libimagentryfilter | |
parent | 12443f631bf3ccc6ccb09d60ec59e837cee62400 (diff) |
Add builtin header check: Field exists
Diffstat (limited to 'libimagentryfilter')
-rw-r--r-- | libimagentryfilter/src/builtin/header/field_exists.rs | 31 | ||||
-rw-r--r-- | libimagentryfilter/src/builtin/header/mod.rs | 3 |
2 files changed, 33 insertions, 1 deletions
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; - |