pub struct RegexPatternMatcher { /* private fields */ }Expand description
Pattern matcher implementation using the regex crate.
§Compile-cache contract
Each unique pattern: &str argument MUST be compiled at most once
per RegexPatternMatcher instance. Pre-fix the trait methods
(find_matches, is_match, captures_iter) called Regex::new
on every invocation, which on the rule-engine hot path recompiles
the same regex hundreds of times per scan and, with adversarial
rule packs, scales to a viable denial-of-service. The internal
cache is a Mutex<HashMap> so concurrent scanners observe a
single compiled Arc<Regex> per pattern; contention is minimal
because the cache is consulted on the (rare) cold path only.
Implementations§
Trait Implementations§
Source§impl Clone for RegexPatternMatcher
impl Clone for RegexPatternMatcher
Source§fn clone(&self) -> RegexPatternMatcher
fn clone(&self) -> RegexPatternMatcher
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RegexPatternMatcher
impl Debug for RegexPatternMatcher
Source§impl Default for RegexPatternMatcher
impl Default for RegexPatternMatcher
Source§fn default() -> RegexPatternMatcher
fn default() -> RegexPatternMatcher
Returns the “default value” for a type. Read more
Source§impl PatternMatcher for RegexPatternMatcher
impl PatternMatcher for RegexPatternMatcher
Source§fn find_matches(&self, pattern: &str, text: &str) -> Vec<PatternMatch>
fn find_matches(&self, pattern: &str, text: &str) -> Vec<PatternMatch>
Find all matches of a pattern in the given text Read more
Source§fn is_match(&self, pattern: &str, text: &str) -> bool
fn is_match(&self, pattern: &str, text: &str) -> bool
Check whether a pattern occurs in the given text. Read more
Source§fn captures_iter(&self, pattern: &str, text: &str) -> Vec<Captures>
fn captures_iter(&self, pattern: &str, text: &str) -> Vec<Captures>
Iterate captures (full match plus capture groups) over a pattern. Read more
Source§fn compile(&self, pattern: &str) -> Result<CompiledPattern, PatternError>
fn compile(&self, pattern: &str) -> Result<CompiledPattern, PatternError>
Compile a pattern for efficient reuse Read more
Auto Trait Implementations§
impl Freeze for RegexPatternMatcher
impl RefUnwindSafe for RegexPatternMatcher
impl Send for RegexPatternMatcher
impl Sync for RegexPatternMatcher
impl Unpin for RegexPatternMatcher
impl UnsafeUnpin for RegexPatternMatcher
impl UnwindSafe for RegexPatternMatcher
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