Trie

Trait Trie 

Source
pub trait Trie<L: TrieLayout> {
    // Required methods
    fn root(&self) -> &TrieHash<L>;
    fn get_with<'a, 'key, Q: Query<L::Hash>>(
        &'a self,
        key: &'key [u8],
        query: Q,
    ) -> Result<Option<Q::Item>, TrieHash<L>, CError<L>>
       where 'a: 'key;
    fn iter<'a>(
        &'a self,
    ) -> Result<Box<dyn TrieIterator<L, Item = TrieItem<'_, TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>;

    // Provided methods
    fn is_empty(&self) -> bool { ... }
    fn contains(&self, key: &[u8]) -> Result<bool, TrieHash<L>, CError<L>> { ... }
    fn get<'a, 'key>(
        &'a self,
        key: &'key [u8],
    ) -> Result<Option<DBValue>, TrieHash<L>, CError<L>>
       where 'a: 'key { ... }
}
Expand description

A key-value datastore implemented as a database-backed modified Merkle tree.

Required Methods§

Source

fn root(&self) -> &TrieHash<L>

Return the root of the trie.

Source

fn get_with<'a, 'key, Q: Query<L::Hash>>( &'a self, key: &'key [u8], query: Q, ) -> Result<Option<Q::Item>, TrieHash<L>, CError<L>>
where 'a: 'key,

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 = TrieItem<'_, TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>

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

Provided Methods§

Source

fn is_empty(&self) -> bool

Is the trie empty?

Source

fn contains(&self, key: &[u8]) -> Result<bool, TrieHash<L>, CError<L>>

Does the trie contain a given key?

Source

fn get<'a, 'key>( &'a self, key: &'key [u8], ) -> Result<Option<DBValue>, TrieHash<L>, CError<L>>
where 'a: 'key,

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

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§

Source§

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

Source§

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

Source§

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

Source§

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