Skip to main content

TrieIndex

Trait TrieIndex 

Source
pub trait TrieIndex:
    Copy
    + Clone
    + Default
    + PartialEq
    + Eq
    + Debug
    + 'static {
    // Required methods
    fn as_usize(self) -> usize;
    fn max_value() -> usize;
    fn zero() -> Self;
    fn max_value_sentinel() -> Self;
    fn from_usize(n: usize) -> Self;
    fn children_mask(children: &[Self; 16]) -> u16;
}
Expand description

Trait for types used as arena/key indices and prefix lengths in NibbleTrie.

Implemented for u8, u16, u32, and u64. The type parameter PTR (pointer type) controls the width of children, leaf, and arena indices. The type parameter LEN (length type) controls the width of prefix_len and key lengths in the index.

Required Methods§

Source

fn as_usize(self) -> usize

Convert to usize for indexing.

Source

fn max_value() -> usize

Maximum representable value (e.g. u16::MAX for u16).

Source

fn zero() -> Self

Zero value, used for initial values and as the OptNz empty sentinel.

Source

fn max_value_sentinel() -> Self

Maximum value used as sentinel for empty slots in children[] by the sibling tries (fixed_len_nibble_trie, nib_trie). nibble_trie itself uses 0 as its sentinel (see OptNz), but keeps this method so the trait stays shared.

Source

fn from_usize(n: usize) -> Self

Convert from usize. May panic or truncate on overflow in debug builds.

Source

fn children_mask(children: &[Self; 16]) -> u16

Compute a 16-bit occupancy mask from a 16-slot children array. Bit N is set if children[N] is not zero.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TrieIndex for u8

Source§

fn as_usize(self) -> usize

Source§

fn max_value() -> usize

Source§

fn zero() -> Self

Source§

fn max_value_sentinel() -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

fn children_mask(children: &[Self; 16]) -> u16

Source§

impl TrieIndex for u16

Source§

fn as_usize(self) -> usize

Source§

fn max_value() -> usize

Source§

fn zero() -> Self

Source§

fn max_value_sentinel() -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

fn children_mask(children: &[Self; 16]) -> u16

Source§

impl TrieIndex for u32

Source§

fn as_usize(self) -> usize

Source§

fn max_value() -> usize

Source§

fn zero() -> Self

Source§

fn max_value_sentinel() -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

fn children_mask(children: &[Self; 16]) -> u16

Source§

impl TrieIndex for u64

Source§

fn as_usize(self) -> usize

Source§

fn max_value() -> usize

Source§

fn zero() -> Self

Source§

fn max_value_sentinel() -> Self

Source§

fn from_usize(n: usize) -> Self

Source§

fn children_mask(children: &[Self; 16]) -> u16

Implementors§