Skip to main content

TrieKeyAdapter

Trait TrieKeyAdapter 

Source
pub trait TrieKeyAdapter:
    Clone
    + Send
    + Sync
    + 'static {
    type AccountKey: Key + From<Nibbles> + Clone;
    type StorageSubKey: Key + From<Nibbles> + Clone + PartialEq;
    type StorageValue: Value + StorageTrieEntryLike<SubKey = Self::StorageSubKey>;

    // Required methods
    fn account_key_to_nibbles(key: &Self::AccountKey) -> Nibbles;
    fn subkey_to_nibbles(subkey: &Self::StorageSubKey) -> Nibbles;
}
Available on crate features trie and trie-db only.
Expand description

Trait abstracting nibble encoding for trie keys.

Allows the same cursor implementation to work with both legacy (65-byte) and packed (33-byte) nibble encodings. The underlying cursor types are monomorphized per adapter, while DatabaseTrieCursorFactory selects the encoding at runtime.

Required Associated Types§

Source

type AccountKey: Key + From<Nibbles> + Clone

The key type for account trie lookups (e.g., StoredNibbles or PackedStoredNibbles).

Source

type StorageSubKey: Key + From<Nibbles> + Clone + PartialEq

The subkey type for storage trie DupSort lookups (e.g., StoredNibblesSubKey or PackedStoredNibblesSubKey).

Source

type StorageValue: Value + StorageTrieEntryLike<SubKey = Self::StorageSubKey>

The storage trie entry type that pairs a subkey with a BranchNodeCompact.

Required Methods§

Source

fn account_key_to_nibbles(key: &Self::AccountKey) -> Nibbles

Convert an account key back to Nibbles.

Source

fn subkey_to_nibbles(subkey: &Self::StorageSubKey) -> Nibbles

Convert a storage subkey back to Nibbles.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§