Struct aho_corasick::util::prefilter::StartBytesBuilder
source · struct StartBytesBuilder {
ascii_case_insensitive: bool,
byteset: Vec<bool>,
count: usize,
rank_sum: u16,
}
Expand description
A builder for constructing a starting byte prefilter.
A starting byte prefilter is a simplistic prefilter that looks for possible
matches by reporting all positions corresponding to a particular byte. This
generally only takes affect when there are at most 3 distinct possible
starting bytes. e.g., the patterns foo
, bar
, and baz
have two
distinct starting bytes (f
and b
), and this prefilter returns all
occurrences of either f
or b
.
In some cases, a heuristic frequency analysis may determine that it would be better not to use this prefilter even when there are 3 or fewer distinct starting bytes.
Fields§
§ascii_case_insensitive: bool
Whether this prefilter should account for ASCII case insensitivity or not.
byteset: Vec<bool>
The set of starting bytes observed.
count: usize
The number of bytes set to true in byteset
.
rank_sum: u16
The sum of frequency ranks for the rare bytes detected. This is intended to give a heuristic notion of how rare the bytes are.
Implementations§
source§impl StartBytesBuilder
impl StartBytesBuilder
sourcefn new() -> StartBytesBuilder
fn new() -> StartBytesBuilder
Create a new builder for constructing a start byte prefilter.
sourcefn ascii_case_insensitive(self, yes: bool) -> StartBytesBuilder
fn ascii_case_insensitive(self, yes: bool) -> StartBytesBuilder
Enable ASCII case insensitivity. When set, byte strings added to this builder will be interpreted without respect to ASCII case.
sourcefn build(&self) -> Option<Prefilter>
fn build(&self) -> Option<Prefilter>
Build the starting bytes prefilter.
If there are more than 3 distinct starting bytes, or if heuristics
otherwise determine that this prefilter should not be used, then None
is returned.
sourcefn add(&mut self, bytes: &[u8])
fn add(&mut self, bytes: &[u8])
Add a byte string to this builder.
All patterns added to an Aho-Corasick automaton should be added to this builder before attempting to construct the prefilter.
fn add_one_byte(&mut self, byte: u8)
Trait Implementations§
source§impl Clone for StartBytesBuilder
impl Clone for StartBytesBuilder
source§fn clone(&self) -> StartBytesBuilder
fn clone(&self) -> StartBytesBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for StartBytesBuilder
impl RefUnwindSafe for StartBytesBuilder
impl Send for StartBytesBuilder
impl Sync for StartBytesBuilder
impl Unpin for StartBytesBuilder
impl UnwindSafe for StartBytesBuilder
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)