Skip to main content

TrieKey

Trait TrieKey 

Source
pub trait TrieKey: Default {
    type Store: KeyStore<Self>;

    // Required method
    fn as_bytes(&self) -> &[u8] ;
}
Expand description

A key type that can be stored in a trie.

Each key type chooses its storage backend via the associated Store type. The as_bytes() method provides the byte representation used for trie traversal (bit extraction, divergence comparison).

The Default bound is required because both store backends reserve index 0 as a dummy entry (so that key index 0 can serve as the “empty” sentinel in node children arrays). K::default() becomes the dummy entry in VecKeyStore.

Required Associated Types§

Source

type Store: KeyStore<Self>

The storage backend for this key type.

Required Methods§

Source

fn as_bytes(&self) -> &[u8]

Return the byte representation of this key for trie traversal.

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 TrieKey for String

Source§

type Store = VecKeyStore<String>

Source§

fn as_bytes(&self) -> &[u8]

Source§

impl TrieKey for Vec<u8>

Source§

type Store = BufKeyStore

Source§

fn as_bytes(&self) -> &[u8]

Implementors§