Enum aho_corasick::nfa::contiguous::StateTrans

source ·
enum StateTrans<'a> {
    Sparse {
        classes: &'a [u32],
        nexts: &'a [u32],
    },
    One {
        class: u8,
        next: u32,
    },
    Dense {
        class_to_next: &'a [u32],
    },
}
Expand description

The underlying representation of sparse or dense transitions for a state.

Note that like State, we don’t typically construct values of this type during a search since we don’t always need all values and thus would represent a lot of wasteful work.

Variants§

§

Sparse

A sparse representation of transitions for a state, where only non-FAIL transitions are explicitly represented.

Fields

§classes: &'a [u32]
§nexts: &'a [u32]

The transitions for this state, where each transition is packed into a u32. The low 8 bits correspond to the byte class for the transition, and the high 24 bits correspond to the next state ID.

This packing is why the max state ID allowed for a contiguous NFA is 2^24-1.

§

One

A “one transition” state that is never a match state.

These are by far the most common state, so we use a specialized and very compact representation for them.

Fields

§class: u8

The element of this NFA’s alphabet that this transition is defined for.

§next: u32

The state this should transition to if the current symbol is equal to ‘class’.

§

Dense

A dense representation of transitions for a state, where all transitions are explicitly represented, including transitions to the FAIL state.

Fields

§class_to_next: &'a [u32]

A dense set of transitions to other states. The transitions may point to a FAIL state, in which case, the search should try the same transition lookup at ‘fail’.

Note that this is indexed by byte equivalence classes and not byte values. That means ‘class_to_next[byte]’ is wrong and ‘class_to_next[classes.get(byte)]’ is correct. The number of transitions is always equivalent to ‘classes.alphabet_len()’.

Trait Implementations§

source§

impl<'a> Clone for StateTrans<'a>

source§

fn clone(&self) -> StateTrans<'a>

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

Auto Trait Implementations§

§

impl<'a> Freeze for StateTrans<'a>

§

impl<'a> RefUnwindSafe for StateTrans<'a>

§

impl<'a> Send for StateTrans<'a>

§

impl<'a> Sync for StateTrans<'a>

§

impl<'a> Unpin for StateTrans<'a>

§

impl<'a> UnwindSafe for StateTrans<'a>

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.