Skip to main content

CompiledFilter

Struct CompiledFilter 

Source
pub struct CompiledFilter { /* private fields */ }
Expand description

A compiled filter ready for evaluation.

This struct contains the bytecode and all pre-compiled resources needed for fast evaluation. Create one at startup and reuse it for all payload evaluations.

Implementations§

Source§

impl CompiledFilter

Source

pub fn new( bytecode: Vec<u8>, strings: Vec<Vec<u8>>, regexes: Vec<Regex>, string_sets: Vec<Vec<u16>>, delimiter: Vec<u8>, source: String, ) -> Self

Create a new compiled filter from components.

This is typically called by the compiler, not directly.

Source

pub fn evaluate(&self, payload: Bytes) -> bool

Evaluate the filter against a record.

§Arguments
  • payload - The record payload to evaluate
§Returns

true if the filter matches, false otherwise.

§Performance
  • Zero allocations during evaluation
  • SIMD-accelerated string matching
  • Fixed-size stack (no heap)
§Panics

In debug builds only, panics if the bytecode is malformed (invalid opcode or stack overflow). In release builds, returns false for invalid bytecode.

Source

pub fn source(&self) -> &str

Get the original filter source.

Source

pub fn bytecode_len(&self) -> usize

Get the bytecode length.

Source

pub fn string_count(&self) -> usize

Get the number of string literals.

Source

pub fn regex_count(&self) -> usize

Get the number of regex patterns.

Source

pub fn delimiter(&self) -> &[u8]

Get the delimiter used for splitting.

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.