pub struct Query(/* private fields */);
Expand description
A set of predicates and options used to select packets
The supported predicate fields are found in PredicateType. The known options are found in KnownOptions.
let mut query = lk_query(&Q);
// Add multiple predicates and options at once.
let query_str = [
"group:=:[#:pub]",
"domain:=:[a:hello]",
"prefix:=:/some/space",
":qid:default"
];
query = lk_query_parse(query,&query_str,())?;
// Optionally with user data such as an argv
query = lk_query_parse(query,&["prefix:=:/some/[0]"],&[b"space" as &[u8]])?;
// conflicting predicates return an error
let result = lk_query_parse(lk_query(&query), &["depth:=:[u8:0]"],());
assert!( result.is_err());
// You can add a single statement directly
query = lk_query_push(query,"create","<", &*now())?;
// Predicates get merged if they overlap
query = lk_query_push(query,"create","<",&lk_eval("[now:-1D]",())?)?;
// As shown with:
println!("{}",lk_query_print(&query,false));
Unlike predicates, options are non-associative. i.e. the order in which they’re added matters. ‘push’ and ‘parse’ add them to the top of the query. In string form you find the matching option by reading from top to bottom.
a set of predicates and options to select/filter packets
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnwindSafe for Query
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