Trait sp_trie::Trie

source ·
pub trait Trie<L>where
    L: TrieLayout,{
    // Required methods
    fn root(&self) -> &<<L as TrieLayout>::Hash as Hasher>::Out;
    fn get_hash(
        &self,
        key: &[u8]
    ) -> Result<Option<<<L as TrieLayout>::Hash as Hasher>::Out>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>;
    fn get_with<Q>(
        &self,
        key: &[u8],
        query: Q
    ) -> Result<Option<<Q as Query<<L as TrieLayout>::Hash>>::Item>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>
       where Q: Query<<L as TrieLayout>::Hash>;
    fn iter<'a>(
        &'a self
    ) -> Result<Box<dyn TrieIterator<L, Item = Result<(Vec<u8, Global>, Vec<u8, Global>), Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>> + 'a, Global>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>;
    fn key_iter<'a>(
        &'a self
    ) -> Result<Box<dyn TrieIterator<L, Item = Result<Vec<u8, Global>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>> + 'a, Global>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn contains(
        &self,
        key: &[u8]
    ) -> Result<bool, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>> { ... }
    fn get(
        &self,
        key: &[u8]
    ) -> Result<Option<Vec<u8, Global>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>> { ... }
}
Expand description

Various re-exports from the trie-db crate. A key-value datastore implemented as a database-backed modified Merkle tree.

Required Methods§

source

fn root(&self) -> &<<L as TrieLayout>::Hash as Hasher>::Out

Return the root of the trie.

source

fn get_hash( &self, key: &[u8] ) -> Result<Option<<<L as TrieLayout>::Hash as Hasher>::Out>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>

Returns the hash of the value for key.

source

fn get_with<Q>( &self, key: &[u8], query: Q ) -> Result<Option<<Q as Query<<L as TrieLayout>::Hash>>::Item>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>where Q: Query<<L as TrieLayout>::Hash>,

Search for the key with the given query parameter. See the docs of the Query trait for more details.

source

fn iter<'a>( &'a self ) -> Result<Box<dyn TrieIterator<L, Item = Result<(Vec<u8, Global>, Vec<u8, Global>), Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>> + 'a, Global>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>

Returns a depth-first iterator over the elements of trie.

source

fn key_iter<'a>( &'a self ) -> Result<Box<dyn TrieIterator<L, Item = Result<Vec<u8, Global>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>> + 'a, Global>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>

Returns a depth-first iterator over the keys of elemets of trie.

Provided Methods§

source

fn is_empty(&self) -> bool

Is the trie empty?

source

fn contains( &self, key: &[u8] ) -> Result<bool, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>

Does the trie contain a given key?

source

fn get( &self, key: &[u8] ) -> Result<Option<Vec<u8, Global>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>

What is the value of the given key in this trie?

Implementors§

source§

impl<'db, 'cache, L> Trie<L> for TrieKinds<'db, 'cache, L>where L: TrieLayout,

source§

impl<'db, 'cache, L> Trie<L> for FatDB<'db, 'cache, L>where L: TrieLayout,

source§

impl<'db, 'cache, L> Trie<L> for SecTrieDB<'db, 'cache, L>where L: TrieLayout,

source§

impl<'db, 'cache, L> Trie<L> for TrieDB<'db, 'cache, L>where L: TrieLayout,