Struct adblock::regex_manager::RegexManager
source · pub struct RegexManager { /* private fields */ }
Expand description
A manager that creates and stores all regular expressions used by filters. Rarely used entries are discarded to save memory.
The RegexManager
is not thread safe, so any access to it must be synchronized externally.
Implementations§
source§impl RegexManager
impl RegexManager
sourcepub fn matches(&mut self, filter: &NetworkFilter, pattern: &str) -> bool
pub fn matches(&mut self, filter: &NetworkFilter, pattern: &str) -> bool
Check whether or not a regex network filter matches a certain URL pattern, using the
RegexManager
’s managed regex storage.
sourcepub fn update_time(&mut self)
pub fn update_time(&mut self)
The RegexManager
is just a struct and doesn’t manage any worker threads, so this method
must be called periodically to ensure that it can track usage patterns of regexes over
time. This method will handle periodically discarding filters if necessary.
sourcepub fn set_discard_policy(
&mut self,
new_discard_policy: RegexManagerDiscardPolicy,
)
pub fn set_discard_policy( &mut self, new_discard_policy: RegexManagerDiscardPolicy, )
Customize the discard behavior of this RegexManager
.
Trait Implementations§
source§impl Default for RegexManager
impl Default for RegexManager
impl Send for RegexManager
*const NetworkFilter
could technically leak across threads through RegexDebugEntry::id
, but
it’s disguised as a unique identifier and not intended to be dereferenced.