Add filter: VersionInRange, VersionOutOfRange
This commit is contained in:
parent
21013dd76f
commit
98dde5d0d1
2 changed files with 52 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
pub mod eq;
|
||||
pub mod lt;
|
||||
pub mod gt;
|
||||
pub mod lt;
|
||||
pub mod range;
|
||||
|
|
50
libimagentryfilter/src/builtin/header/version/range.rs
Normal file
50
libimagentryfilter/src/builtin/header/version/range.rs
Normal file
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in a new issue