Skip to main content

Matcher

Struct Matcher 

Source
pub struct Matcher<'a> { /* private fields */ }
Expand description

The NFA-based matching engine.

Implementations§

Source§

impl<'a> Matcher<'a>

Source

pub fn new( nfa: &'a Nfa, fuzzy_bridge: Option<&'a FuzzyBridge>, capture_count: usize, config: MatcherConfig, ) -> Self

Create a new matcher.

Source

pub fn with_prefilter( nfa: &'a Nfa, fuzzy_bridge: Option<&'a FuzzyBridge>, capture_count: usize, config: MatcherConfig, prefilter: Arc<Prefilter>, ) -> Self

Create a new matcher with a prefilter.

Source

pub fn find(&self, text: &str) -> Option<MatchResult>

Find the first match in the text (or best match in BESTMATCH mode).

Source

pub fn find_all(&self, text: &str) -> Vec<MatchResult>

Find all non-overlapping matches.

Source

pub fn find_n(&self, text: &str, n: usize) -> Vec<MatchResult>

Find up to n non-overlapping matches.

This is more efficient than find_all when only a limited number of matches is needed, as it stops searching after finding n matches.

Source

pub fn find_at(&self, text: &str, start: usize) -> Option<MatchResult>

Try to find a match starting at a specific position.

Unlike find() which searches the entire text, this starts the search at the given position. The full text is still used for boundary checks (e.g., \b word boundaries).

Source

pub fn build_cache(&self, text: &str) -> Option<CachedMatches>

Build the fuzzy cache for the given text.

This can be used for lazy iteration where we want to compute the cache once upfront and reuse it for multiple find_at_with_cache calls.

Source

pub fn find_at_with_cache( &self, text: &str, start: usize, cached: Option<&CachedMatches>, ) -> Option<MatchResult>

Try to find a match starting at a specific position using cached fuzzy matches.

Auto Trait Implementations§

§

impl<'a> Freeze for Matcher<'a>

§

impl<'a> !RefUnwindSafe for Matcher<'a>

§

impl<'a> !Send for Matcher<'a>

§

impl<'a> !Sync for Matcher<'a>

§

impl<'a> Unpin for Matcher<'a>

§

impl<'a> UnsafeUnpin for Matcher<'a>

§

impl<'a> !UnwindSafe for Matcher<'a>

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.