Trait regex_automata::util::prefilter::PrefilterI
source · pub(crate) trait PrefilterI: Debug + Send + Sync + RefUnwindSafe + UnwindSafe + 'static {
// Required methods
fn find(&self, haystack: &[u8], span: Span) -> Option<Span>;
fn prefix(&self, haystack: &[u8], span: Span) -> Option<Span>;
fn memory_usage(&self) -> usize;
fn is_fast(&self) -> bool;
}
Expand description
A trait for abstracting over prefilters. Basically, a prefilter is something that do an unanchored and an anchored search in a haystack within a given span.
This exists pretty much only so that we can use prefilters as a trait
object (which is what Prefilter
is). If we ever move off of trait objects
and to an enum, then it’s likely this trait could be removed.
Required Methods§
sourcefn find(&self, haystack: &[u8], span: Span) -> Option<Span>
fn find(&self, haystack: &[u8], span: Span) -> Option<Span>
Run this prefilter on haystack[span.start..end]
and return a matching
span if one exists.
The span returned is guaranteed to have a start position greater than or equal to the one given, and an end position less than or equal to the one given.
sourcefn prefix(&self, haystack: &[u8], span: Span) -> Option<Span>
fn prefix(&self, haystack: &[u8], span: Span) -> Option<Span>
Returns the span of a prefix of haystack[span.start..span.end]
if
the prefilter matches.
The span returned is guaranteed to have a start position equivalent to the one given, and an end position less than or equal to the one given.
sourcefn memory_usage(&self) -> usize
fn memory_usage(&self) -> usize
Returns the heap memory, in bytes, used by the underlying prefilter.
sourcefn is_fast(&self) -> bool
fn is_fast(&self) -> bool
Implementations might return true here if they believe themselves to
be “fast.” See Prefilter::is_fast
for more details.