pub enum MetadataFilter {
Condition(Condition),
And(Vec<MetadataFilter>),
Or(Vec<MetadataFilter>),
Not(Box<MetadataFilter>),
}Expand description
A composable filter expression over Metadata.
Filters can be built from primitive Conditions and combined with
MetadataFilter::and, MetadataFilter::or, and MetadataFilter::not.
§Examples
use qubit_metadata::{Metadata, MetadataFilter};
let mut meta = Metadata::new();
meta.set("env", "prod");
meta.set("version", 2_i64);
let f = MetadataFilter::eq("env", "prod")
.and(MetadataFilter::gte("version", 1_i64));
assert!(f.matches(&meta));Variants§
Condition(Condition)
A leaf condition.
And(Vec<MetadataFilter>)
All child filters must match.
Or(Vec<MetadataFilter>)
At least one child filter must match.
Not(Box<MetadataFilter>)
The child filter must not match.
Implementations§
Source§impl MetadataFilter
impl MetadataFilter
Sourcepub fn eq<T: Serialize>(key: impl Into<String>, value: T) -> Self
pub fn eq<T: Serialize>(key: impl Into<String>, value: T) -> Self
Creates an equality filter: key == value.
Sourcepub fn ne<T: Serialize>(key: impl Into<String>, value: T) -> Self
pub fn ne<T: Serialize>(key: impl Into<String>, value: T) -> Self
Creates a not-equal filter: key != value.
Sourcepub fn gt<T: Serialize>(key: impl Into<String>, value: T) -> Self
pub fn gt<T: Serialize>(key: impl Into<String>, value: T) -> Self
Creates a greater-than filter: key > value.
Sourcepub fn gte<T: Serialize>(key: impl Into<String>, value: T) -> Self
pub fn gte<T: Serialize>(key: impl Into<String>, value: T) -> Self
Creates a greater-than-or-equal filter: key >= value.
Sourcepub fn lt<T: Serialize>(key: impl Into<String>, value: T) -> Self
pub fn lt<T: Serialize>(key: impl Into<String>, value: T) -> Self
Creates a less-than filter: key < value.
Sourcepub fn lte<T: Serialize>(key: impl Into<String>, value: T) -> Self
pub fn lte<T: Serialize>(key: impl Into<String>, value: T) -> Self
Creates a less-than-or-equal filter: key <= value.
Sourcepub fn exists(key: impl Into<String>) -> Self
pub fn exists(key: impl Into<String>) -> Self
Creates an existence filter: the key must be present.
Sourcepub fn not_exists(key: impl Into<String>) -> Self
pub fn not_exists(key: impl Into<String>) -> Self
Creates a non-existence filter: the key must be absent.
Sourcepub fn in_values<T, I>(key: impl Into<String>, values: I) -> Selfwhere
T: Serialize,
I: IntoIterator<Item = T>,
pub fn in_values<T, I>(key: impl Into<String>, values: I) -> Selfwhere
T: Serialize,
I: IntoIterator<Item = T>,
Creates an in-set filter: key ∈ values.
Sourcepub fn not_in_values<T, I>(key: impl Into<String>, values: I) -> Selfwhere
T: Serialize,
I: IntoIterator<Item = T>,
pub fn not_in_values<T, I>(key: impl Into<String>, values: I) -> Selfwhere
T: Serialize,
I: IntoIterator<Item = T>,
Creates a not-in-set filter: key ∉ values.
Sourcepub fn and(self, other: MetadataFilter) -> Self
pub fn and(self, other: MetadataFilter) -> Self
Combines self and other with a logical AND.
If self is already an And node the new filter is appended to its
children rather than creating a new nested node.
Sourcepub fn or(self, other: MetadataFilter) -> Self
pub fn or(self, other: MetadataFilter) -> Self
Combines self and other with a logical OR.
If self is already an Or node the new filter is appended to its
children rather than creating a new nested node.
Trait Implementations§
Source§impl Clone for MetadataFilter
impl Clone for MetadataFilter
Source§fn clone(&self) -> MetadataFilter
fn clone(&self) -> MetadataFilter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more