pub struct MultiPatternEngine { /* private fields */ }
Expand description
Multi-pattern matching engine
Implementations§
Source§impl MultiPatternEngine
impl MultiPatternEngine
Sourcepub fn new(algorithm: Option<MatchAlgorithm>, patterns: &[String]) -> Self
pub fn new(algorithm: Option<MatchAlgorithm>, patterns: &[String]) -> Self
Create a new engine and automatically select the algorithm based on the lexicon size
Sourcepub fn rebuild(&mut self, patterns: &[String])
pub fn rebuild(&mut self, patterns: &[String])
Rebuild the engine (called when the pattern is updated)
Sourcepub fn recommend_algorithm(word_count: usize) -> MatchAlgorithm
pub fn recommend_algorithm(word_count: usize) -> MatchAlgorithm
Recommended algorithm based on the lexicon
Sourcepub fn rebuild_with_algorithm(
&mut self,
patterns: &[String],
algorithm: MatchAlgorithm,
)
pub fn rebuild_with_algorithm( &mut self, patterns: &[String], algorithm: MatchAlgorithm, )
Force rebuild using the specified algorithm
Sourcepub fn current_algorithm(&self) -> MatchAlgorithm
pub fn current_algorithm(&self) -> MatchAlgorithm
Get the currently used algorithm
Sourcepub fn get_patterns(&self) -> &[String]
pub fn get_patterns(&self) -> &[String]
Get all modes
Sourcepub fn find_first(&self, text: &str) -> Option<String>
pub fn find_first(&self, text: &str) -> Option<String>
Find the first match
Sourcepub fn replace_all(&self, text: &str, replacement: &str) -> String
pub fn replace_all(&self, text: &str, replacement: &str) -> String
Replace all matches with optimized performance
Sourcepub fn find_matches_with_positions(&self, text: &str) -> Vec<MatchInfo>
pub fn find_matches_with_positions(&self, text: &str) -> Vec<MatchInfo>
Get detailed match information
Sourcepub fn contains_any(&self, text: &str) -> bool
pub fn contains_any(&self, text: &str) -> bool
Check if text contains any patterns
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MultiPatternEngine
impl RefUnwindSafe for MultiPatternEngine
impl Send for MultiPatternEngine
impl Sync for MultiPatternEngine
impl Unpin for MultiPatternEngine
impl UnwindSafe for MultiPatternEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more