pub struct PatternMatcher { /* private fields */ }Expand description
High-performance pattern matcher using Aho-Corasick for literal patterns and compiled regex for regex patterns
Implementations§
Source§impl PatternMatcher
impl PatternMatcher
Sourcepub fn new(patterns: Vec<Pattern>) -> Result<Self>
pub fn new(patterns: Vec<Pattern>) -> Result<Self>
Create a new pattern matcher from a list of patterns
Sourcepub fn pattern_count(&self) -> usize
pub fn pattern_count(&self) -> usize
Get the total number of patterns
Sourcepub fn find_matches(&self, input: &str) -> Vec<Match>
pub fn find_matches(&self, input: &str) -> Vec<Match>
Find all matches in the input text.
Input is normalized (NFKD + ZWC stripping) before matching to prevent homoglyph and zero-width character bypass attacks.
Sourcepub fn is_match(&self, input: &str) -> bool
pub fn is_match(&self, input: &str) -> bool
Check if the input contains any matches.
Input is normalized (NFKD + ZWC stripping) before matching.
Sourcepub fn find_first(&self, input: &str) -> Option<Match>
pub fn find_first(&self, input: &str) -> Option<Match>
Find the first match in the input.
Input is normalized (NFKD + ZWC stripping) before matching.
Sourcepub fn highest_severity(&self, input: &str) -> Option<Severity>
pub fn highest_severity(&self, input: &str) -> Option<Severity>
Get the highest severity among all matches
Trait Implementations§
Source§impl Debug for PatternMatcher
impl Debug for PatternMatcher
Auto Trait Implementations§
impl Freeze for PatternMatcher
impl RefUnwindSafe for PatternMatcher
impl Send for PatternMatcher
impl Sync for PatternMatcher
impl Unpin for PatternMatcher
impl UnwindSafe for PatternMatcher
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