pub trait Trie<L: TrieLayout> {
fn root(&self) -> &TrieHash<L>;
fn get_hash(
&self,
key: &[u8]
) -> Result<Option<TrieHash<L>>, TrieHash<L>, CError<L>>;
fn get_with<Q: Query<L::Hash>>(
&self,
key: &[u8],
query: Q
) -> Result<Option<Q::Item>, TrieHash<L>, CError<L>>;
fn iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = TrieItem<TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>;
fn key_iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = TrieKeyItem<TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>;
fn is_empty(&self) -> bool { ... }
fn contains(&self, key: &[u8]) -> Result<bool, TrieHash<L>, CError<L>> { ... }
fn get(&self, key: &[u8]) -> Result<Option<DBValue>, TrieHash<L>, CError<L>> { ... }
}
Expand description
A key-value datastore implemented as a database-backed modified Merkle tree.
Required Methods§
sourcefn get_hash(
&self,
key: &[u8]
) -> Result<Option<TrieHash<L>>, TrieHash<L>, CError<L>>
fn get_hash(
&self,
key: &[u8]
) -> Result<Option<TrieHash<L>>, TrieHash<L>, CError<L>>
Returns the hash of the value for key
.
sourcefn get_with<Q: Query<L::Hash>>(
&self,
key: &[u8],
query: Q
) -> Result<Option<Q::Item>, TrieHash<L>, CError<L>>
fn get_with<Q: Query<L::Hash>>(
&self,
key: &[u8],
query: Q
) -> Result<Option<Q::Item>, TrieHash<L>, CError<L>>
Search for the key with the given query parameter. See the docs of the Query
trait for more details.
sourcefn iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = TrieItem<TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>
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.
sourcefn key_iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = TrieKeyItem<TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>
fn key_iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = TrieKeyItem<TrieHash<L>, CError<L>>> + 'a>, TrieHash<L>, CError<L>>
Returns a depth-first iterator over the keys of elemets of trie.