pub struct LiveFilter { /* private fields */ }Expand description
In-memory filter builder for live subscriptions.
The filter DSL mirrors the historical query builder, but it only describes live matching
predicates. Time bounds and cursor resumes are configured through
crate::SubscriptionOptions.
Direct terms are AND-ed together. Each LiveFilter::or_group call adds one alternative
branch whose terms are also AND-ed together.
Implementations§
Source§impl LiveFilter
impl LiveFilter
Sourcepub fn match_exact(&mut self, field: &str, value: &[u8]) -> &mut Self
pub fn match_exact(&mut self, field: &str, value: &[u8]) -> &mut Self
Match entries whose field equals value byte-for-byte.
Multiple terms added directly to a filter are AND-ed together. Validation is deferred until
the filter is registered with crate::LiveJournal::subscribe or
crate::LiveJournal::subscribe_with_options.
Sourcepub fn match_present(&mut self, field: &str) -> &mut Self
pub fn match_present(&mut self, field: &str) -> &mut Self
Match entries that contain field, regardless of its value.
Multiple terms added directly to a filter are AND-ed together. Validation is deferred until
the filter is registered with crate::LiveJournal::subscribe or
crate::LiveJournal::subscribe_with_options.
Sourcepub fn match_unit(&mut self, unit: &str) -> &mut Self
pub fn match_unit(&mut self, unit: &str) -> &mut Self
Match entries for a specific systemd unit.
This expands to an OR over _SYSTEMD_UNIT, UNIT, and OBJECT_SYSTEMD_UNIT.
Sourcepub fn match_unit_bytes(&mut self, unit: &[u8]) -> &mut Self
pub fn match_unit_bytes(&mut self, unit: &[u8]) -> &mut Self
Same as LiveFilter::match_unit, but accepts raw unit bytes.
Sourcepub fn or_group<F>(&mut self, f: F) -> &mut Selfwhere
F: FnOnce(&mut LiveOrGroupBuilder),
pub fn or_group<F>(&mut self, f: F) -> &mut Selfwhere
F: FnOnce(&mut LiveOrGroupBuilder),
Add an OR-group to the filter.
Each call creates one OR branch. Terms added inside the closure are AND-ed together within that branch. Empty groups are ignored.
let mut live = LiveJournal::open_default()?;
let mut filter = live.filter();
filter
.match_present("MESSAGE")
.or_group(|g| {
g.match_exact("_SYSTEMD_UNIT", b"sshd.service");
})
.or_group(|g| {
g.match_exact("_SYSTEMD_UNIT", b"systemd.service");
});
let _subscription = live.subscribe(filter)?;Trait Implementations§
Source§impl Clone for LiveFilter
impl Clone for LiveFilter
Source§fn clone(&self) -> LiveFilter
fn clone(&self) -> LiveFilter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more