Struct StateID

#[repr(transparent)]
pub struct StateID(/* private field */);

The identifier of a finite automaton state, represented by a SmallIndex.

Most regex engines in this crate are built on top of finite automata. Each state in a finite automaton defines transitions from its state to another. Those transitions point to other states via their identifiers, i.e., a StateID. Since finite automata tend to contain many transitions, it is much more memory efficient to define state IDs as small indices.

See the SmallIndex type for more information about what it means for a state ID to be a "small index."

Implementations

impl StateID

const MAX: StateID = _;

The maximum value.

const LIMIT: usize = SmallIndex::LIMIT;

The total number of values that can be represented.

const ZERO: StateID = _;

The zero value.

const SIZE: usize = SmallIndex::SIZE;

The number of bytes that a single value uses in memory.

fn new(value: usize) -> Result<StateID, StateIDError>

Create a new value that is represented by a "small index."

If the given index exceeds the maximum allowed value, then this returns an error.

const fn new_unchecked(value: usize) -> StateID

Create a new value without checking whether the given argument exceeds the maximum.

Using this routine with an invalid value will result in unspecified behavior, but not undefined behavior. In particular, an invalid ID value is likely to cause panics or possibly even silent logical errors.

Callers must never rely on this type to be within a certain range for memory safety.

fn must(value: usize) -> StateID

Like new, but panics if the given value is not valid.

const fn as_usize(&self) -> usize

Return the internal value as a usize. This is guaranteed to never overflow usize.

const fn as_u64(&self) -> u64

Return the internal value as a u64. This is guaranteed to never overflow.

const fn as_u32(&self) -> u32

Return the internal value as a u32. This is guaranteed to never overflow u32.

const fn as_i32(&self) -> i32

Return the internal value as a i32. This is guaranteed to never overflow an i32`.

fn one_more(&self) -> usize

Returns one more than this value as a usize.

Since values represented by a "small index" have constraints on their maximum value, adding 1 to it will always fit in a usize, u32 and a i32.

fn from_ne_bytes(bytes: [u8; 4]) -> Result<StateID, StateIDError>

Decode this value from the bytes given using the native endian byte order for the current target.

If the decoded integer is not representable as a small index for the current target, then this returns an error.

fn from_ne_bytes_unchecked(bytes: [u8; 4]) -> StateID

Decode this value from the bytes given using the native endian byte order for the current target.

This is analogous to new_unchecked in that is does not check whether the decoded integer is representable as a small index.

fn to_ne_bytes(&self) -> [u8; 4]

Return the underlying integer as raw bytes in native endian format.

Trait Implementations

impl Clone for StateID

fn clone(&self) -> Self

impl Copy for StateID

impl Debug for StateID

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

impl Default for StateID

fn default() -> Self

impl Eq for StateID

impl From<u8> for StateID

fn from(value: u8) -> StateID

impl Hash for StateID

fn hash<__H: Hasher>(&self, state: &mut __H)

impl Ord for StateID

fn cmp(&self, other: &Self) -> Ordering

impl PartialEq for StateID

fn eq(&self, other: &Self) -> bool

impl PartialOrd for StateID

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

impl StructuralPartialEq for StateID

impl TryFrom<u16> for StateID

type Error = StateIDError;
fn try_from(value: u16) -> Result<StateID, StateIDError>

impl TryFrom<u32> for StateID

type Error = StateIDError;
fn try_from(value: u32) -> Result<StateID, StateIDError>

impl TryFrom<u64> for StateID

type Error = StateIDError;
fn try_from(value: u64) -> Result<StateID, StateIDError>

impl TryFrom<usize> for StateID

type Error = StateIDError;
fn try_from(value: usize) -> Result<StateID, StateIDError>

Auto Trait Implementations

impl Freeze for StateID

impl RefUnwindSafe for StateID

impl Send for StateID

impl Sync for StateID

impl Unpin for StateID

impl UnsafeUnpin for StateID

impl UnwindSafe for StateID

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> CloneToUninit for StateID where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for StateID

fn from(t: T) -> T

Returns the argument unchanged.

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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