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>>>;
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>>>
where Q: Query<<L as TrieLayout>::Hash>;
fn lookup_first_descendant(
&self,
key: &[u8]
) -> Result<Option<MerkleValue<<<L as TrieLayout>::Hash as Hasher>::Out>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>;
fn iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = Result<(Vec<u8>, Vec<u8>), Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>> + 'a>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>;
fn key_iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = Result<Vec<u8>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>> + 'a>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>;
// 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>>> { ... }
fn get(
&self,
key: &[u8]
) -> Result<Option<Vec<u8>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>> { ... }
}
Expand description
Various re-exports from the trie-db
crate.
A key-value datastore implemented as a database-backed modified Merkle tree.
Required Methods§
sourcefn 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>>>
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>>>
Returns the hash of the value for key
.
sourcefn 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>>>where
Q: Query<<L as TrieLayout>::Hash>,
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>>>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.
sourcefn lookup_first_descendant(
&self,
key: &[u8]
) -> Result<Option<MerkleValue<<<L as TrieLayout>::Hash as Hasher>::Out>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>
fn lookup_first_descendant( &self, key: &[u8] ) -> Result<Option<MerkleValue<<<L as TrieLayout>::Hash as Hasher>::Out>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>
Look up the MerkleValue
of the node that is the closest descendant for the provided
key.
When the provided key leads to a node, then the merkle value of that node
is returned. However, if the key does not lead to a node, then the merkle value
of the closest descendant is returned. None
if no such descendant exists.
sourcefn iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = Result<(Vec<u8>, Vec<u8>), Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>> + 'a>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>
fn iter<'a>( &'a self ) -> Result<Box<dyn TrieIterator<L, Item = Result<(Vec<u8>, Vec<u8>), Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>> + 'a>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>
Returns a depth-first iterator over the elements of trie.
sourcefn key_iter<'a>(
&'a self
) -> Result<Box<dyn TrieIterator<L, Item = Result<Vec<u8>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>> + 'a>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>
fn key_iter<'a>( &'a self ) -> Result<Box<dyn TrieIterator<L, Item = Result<Vec<u8>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>> + 'a>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>>>
Returns a depth-first iterator over the keys of elemets of trie.
Provided Methods§
Object Safety§
This trait is not object safe.