Trait sp_state_machine::TrieMut
pub trait TrieMut<L>where
L: TrieLayout,{
// Required methods
fn root(&mut self) -> &<<L as TrieLayout>::Hash as Hasher>::Out;
fn is_empty(&self) -> bool;
fn get<'a, 'key>(
&'a self,
key: &'key [u8]
) -> Result<Option<Vec<u8, Global>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>
where 'a: 'key;
fn insert(
&mut self,
key: &[u8],
value: &[u8]
) -> Result<Option<Value<L>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>;
fn remove(
&mut self,
key: &[u8]
) -> Result<Option<Value<L>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>;
// Provided method
fn contains(
&self,
key: &[u8]
) -> Result<bool, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>> { ... }
}
Expand description
A key-value datastore implemented as a database-backed modified Merkle tree.
Required Methods§
fn root(&mut self) -> &<<L as TrieLayout>::Hash as Hasher>::Out
fn root(&mut self) -> &<<L as TrieLayout>::Hash as Hasher>::Out
Return the root of the trie.
fn get<'a, 'key>(
&'a self,
key: &'key [u8]
) -> Result<Option<Vec<u8, Global>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>where
'a: 'key,
fn get<'a, 'key>( &'a self, key: &'key [u8] ) -> Result<Option<Vec<u8, Global>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>where 'a: 'key,
What is the value of the given key in this trie?
fn insert(
&mut self,
key: &[u8],
value: &[u8]
) -> Result<Option<Value<L>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>
fn insert( &mut self, key: &[u8], value: &[u8] ) -> Result<Option<Value<L>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>
Insert a key
/value
pair into the trie. An empty value is equivalent to removing
key
from the trie. Returns the old value associated with this key, if it existed.
fn remove(
&mut self,
key: &[u8]
) -> Result<Option<Value<L>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>
fn remove( &mut self, key: &[u8] ) -> Result<Option<Value<L>>, Box<TrieError<<<L as TrieLayout>::Hash as Hasher>::Out, <<L as TrieLayout>::Codec as NodeCodec>::Error>, Global>>
Remove a key
from the trie. Equivalent to making it equal to the empty
value. Returns the old value associated with this key, if it existed.