pub struct Matcher<'a> { /* private fields */ }Expand description
The NFA-based matching engine.
Implementations§
Source§impl<'a> Matcher<'a>
impl<'a> Matcher<'a>
Sourcepub fn new(
nfa: &'a Nfa,
fuzzy_bridge: Option<&'a FuzzyBridge>,
capture_count: usize,
config: MatcherConfig,
) -> Self
pub fn new( nfa: &'a Nfa, fuzzy_bridge: Option<&'a FuzzyBridge>, capture_count: usize, config: MatcherConfig, ) -> Self
Create a new matcher.
Sourcepub fn with_prefilter(
nfa: &'a Nfa,
fuzzy_bridge: Option<&'a FuzzyBridge>,
capture_count: usize,
config: MatcherConfig,
prefilter: Arc<Prefilter>,
) -> Self
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.
Sourcepub fn find(&self, text: &str) -> Option<MatchResult>
pub fn find(&self, text: &str) -> Option<MatchResult>
Find the first match in the text (or best match in BESTMATCH mode).
Sourcepub fn find_all(&self, text: &str) -> Vec<MatchResult>
pub fn find_all(&self, text: &str) -> Vec<MatchResult>
Find all non-overlapping matches.
Sourcepub fn find_n(&self, text: &str, n: usize) -> Vec<MatchResult>
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.
Sourcepub fn find_at(&self, text: &str, start: usize) -> Option<MatchResult>
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).
Sourcepub fn build_cache(&self, text: &str) -> Option<CachedMatches>
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.
Sourcepub fn find_at_with_cache(
&self,
text: &str,
start: usize,
cached: Option<&CachedMatches>,
) -> Option<MatchResult>
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.