Matcher

Struct Matcher 

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

The pattern matching engine.

Implementations§

Source§

impl Matcher

Source

pub fn new(buffer_size: usize) -> Self

Create a new matcher with the specified buffer size.

Source

pub fn with_cache(buffer_size: usize, cache: Arc<RegexCache>) -> Self

Create a new matcher with shared regex cache.

Source

pub const fn set_default_timeout(&mut self, timeout: Duration)

Set the default timeout.

Source

pub const fn set_search_window(&mut self, size: Option<usize>)

Set the search window size.

When set, pattern matching will only search the last N bytes of the buffer, improving performance for large buffers.

Source

pub fn append(&mut self, data: &[u8])

Append data to the buffer.

Source

pub const fn buffer(&self) -> &RingBuffer

Get the current buffer.

Source

pub fn buffer_str(&mut self) -> String

Get the current buffer contents as a string.

Source

pub fn clear(&mut self)

Clear the buffer.

Source

pub fn try_match(&mut self, pattern: &Pattern) -> Option<MatchResult>

Try to match a single pattern against the buffer.

Source

pub fn try_match_any(&mut self, patterns: &PatternSet) -> Option<MatchResult>

Try to match any pattern from a set against the buffer.

Source

pub fn consume_match(&mut self, result: &MatchResult) -> Match

Consume matched content from the buffer and return a Match.

Source

pub fn get_timeout(&self, patterns: &PatternSet) -> Duration

Get the timeout for a pattern set.

Source

pub const fn cache(&self) -> &Arc<RegexCache>

Get the regex cache.

Trait Implementations§

Source§

impl Default for Matcher

Source§

fn default() -> Self

Returns the “default value” for a type. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V