summaryrefslogtreecommitdiffstats
path: root/libimagentryfilter
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2016-03-15 23:18:11 +0100
committerMatthias Beyer <mail@beyermatthias.de>2016-03-18 14:33:43 +0100
commit98dde5d0d15588927c59623cd025a16fb5f53f10 (patch)
tree09fb5776246335761a6bf07d074907c8683675c4 /libimagentryfilter
parent21013dd76f47747b69ba92660d2cd84af1b4fc5d (diff)
Add filter: VersionInRange, VersionOutOfRange
Diffstat (limited to 'libimagentryfilter')
-rw-r--r--libimagentryfilter/src/builtin/header/version/mod.rs3
-rw-r--r--libimagentryfilter/src/builtin/header/version/range.rs50
2 files changed, 52 insertions, 1 deletions
diff --git a/libimagentryfilter/src/builtin/header/version/mod.rs b/libimagentryfilter/src/builtin/header/version/mod.rs
index 5120056d..a2e86826 100644
--- a/libimagentryfilter/src/builtin/header/version/mod.rs
+++ b/libimagentryfilter/src/builtin/header/version/mod.rs
@@ -1,3 +1,4 @@
pub mod eq;
-pub mod lt;
pub mod gt;
+pub mod lt;
+pub mod range;
diff --git a/libimagentryfilter/src/builtin/header/version/range.rs b/libimagentryfilter/src/builtin/header/version/range.rs
new file mode 100644
index 00000000..9dffe5d6
--- /dev/null
+++ b/libimagentryfilter/src/builtin/header/version/range.rs
@@ -0,0 +1,50 @@
+use semver::Version;
+
+use libimagstore::store::Entry;
+
+use builtin::header::version::gt::VersionGt;
+use builtin::header::version::lt::VersionLt;
+use filter::Filter;
+use ops::and::And;
+use ops::not::Not;
+
+pub struct VersionInRange {
+ and: And,
+}
+
+impl VersionInRange {
+
+ pub fn new(lowerbound: Version, upperbound: Version) -> VersionInRange {
+ VersionInRange { and: VersionGt::new(lowerbound).and(Box::new(VersionLt::new(upperbound))) }
+ }
+
+}
+
+impl Filter for VersionInRange {
+
+ fn filter(&self, e: &Entry) -> bool {
+ self.and.filter(e)
+ }
+
+}
+
+pub struct VersionOutOfRange {
+ not: Not
+}
+
+impl VersionOutOfRange {
+
+ pub fn new(lowerbound: Version, upperbound: Version) -> VersionOutOfRange {
+ VersionOutOfRange { not: VersionInRange::new(lowerbound, upperbound).not() }
+ }
+
+}
+
+impl Filter for VersionOutOfRange {
+
+ fn filter(&self, e: &Entry) -> bool {
+ self.not.filter(e)
+ }
+
+}
+