Skip to main content

CompiledFilter

Struct CompiledFilter 

Source
pub struct CompiledFilter {
    pub format_name: String,
    /* private fields */
}
Expand description

A compiled filter bound to a specific format. Evaluating a line runs the format’s regex once and applies all predicates against the resulting captures. AND semantics: a line matches iff every predicate matches.

format_regex_record is a sibling compiled from the same source pattern with dotall + multi-line flags enabled. Records-mode callers use it so greedy . / .+ captures span across newlines within a single record (e.g. (?P<message>.*)$ captures the entire record body instead of failing because the original $ only matches end-of-input).

Fields§

§format_name: String

Implementations§

Source§

impl CompiledFilter

Source

pub fn compile( format: &LogFormat, specs: Vec<FilterSpec>, case_mode: CaseMode, ) -> Result<Self, String>

Compile the given specs against format. Validates that every spec’s field is one of the format’s named captures. The case_mode applies to the regex operators (~ / !~); literal-comparison operators (=, !=, <, <=, >, >=) ignore it.

Source

pub fn evaluate(&self, line: &[u8]) -> FilterMatch

Evaluate the filter against a single logical line of bytes. Decodes the line as UTF-8 with a lossy fallback so non-UTF-8 bytes can still flow through (they just won’t match string-equal predicates).

Source

pub fn evaluate_record(&self, record: &[u8]) -> FilterMatch

Records-mode evaluation: runs the format regex with dotall + multi-line flags enabled against the full multi-line record bytes. Greedy captures like (?P<message>.*)$ consume the whole body of the record, so predicates can match content on any continuation line.

Trait Implementations§

Source§

impl Debug for CompiledFilter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.