pub struct RegexPool { /* private fields */ }Expand description
Thread-safe, size-bounded FIFO cache for compiled Regex objects.
Most useful in daemon mode where the same patterns are queried repeatedly.
Set max_entries to 0 for unlimited capacity.
Implementations§
Source§impl RegexPool
impl RegexPool
Sourcepub fn new(max_entries: usize) -> Self
pub fn new(max_entries: usize) -> Self
Create a pool with the given maximum entry count (0 = unlimited).
Sourcepub fn get_or_compile(&self, pattern: &str) -> Result<Regex, Error>
pub fn get_or_compile(&self, pattern: &str) -> Result<Regex, Error>
Returns a compiled Regex for the given pattern, using the cached copy if available.
§Errors
Returns regex::Error if the pattern fails to compile.
Sourcepub fn invalidate(&self, pattern: &str)
pub fn invalidate(&self, pattern: &str)
Removes a specific pattern from the pool.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RegexPool
impl RefUnwindSafe for RegexPool
impl Send for RegexPool
impl Sync for RegexPool
impl Unpin for RegexPool
impl UnsafeUnpin for RegexPool
impl UnwindSafe for RegexPool
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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