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

source

fn new() -> StartBytesBuilder

Create a new builder for constructing a start byte prefilter.

source

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.

source

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.

source

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.

source

fn add_one_byte(&mut self, byte: u8)

Trait Implementations§

source§

impl Clone for StartBytesBuilder

source§

fn clone(&self) -> StartBytesBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for StartBytesBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.