pub struct LkQuery(/* private fields */);
Expand description
A set of predicates and options used to select a range of packets
The supported predicate fields are PredicateType. The known options are KnownOptions.
// Add multiple predicates and options at once.
let query_str = r#"
group = [#:pub]
domain = [a:hello]
prefix = /some/path
"#;
let mut query = lkq_new(&query_str,&())?;
// the domain:group:prefix is so common it has an allias [lkq_space]
// As these are AB-Expressions they are evaluated in the [UserScope] context
lkq_add_mut(&mut query,"prefix = /some/[0]",&[b"path" as &[u8]])?;
{
// add the predicate that the stamp should hold a value less 100
let mut query_with_stamp = lkq_add(&query, &"stamp < [u64:100]",&())?;
// conflicting predicates are not allowed
let result = lkq_add_mut(&mut query_with_stamp, &"stamp > [u64:100]",&());
assert!( result.is_err());
}
// When adding only a single predicate you might be able to avoid an encoding step
lkq_insert_mut(&mut query,"stamp","<", &*now())?;
// Predicates get merged if they overlap
lkq_insert_mut(&mut query,"stamp","<",&lka_eval("[now:-1D]",&())?)?;
println!("{}",&lkq_stringify(&query,false));
Unlike predicates, the order in which options are can matter.
Trait Implementations§
impl StructuralPartialEq for LkQuery
Auto Trait Implementations§
impl Freeze for LkQuery
impl RefUnwindSafe for LkQuery
impl Send for LkQuery
impl Sync for LkQuery
impl Unpin for LkQuery
impl UnwindSafe for LkQuery
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more