Enum casper_execution_engine::storage::trie::Trie
source · pub enum Trie<K, V> {
Leaf {
key: K,
value: V,
},
Node {
pointer_block: Box<PointerBlock>,
},
Extension {
affix: Bytes,
pointer: Pointer,
},
}Expand description
Represents a Merkle Trie.
Variants§
Leaf
Trie leaf.
Node
Fields
§
pointer_block: Box<PointerBlock>Node pointer block.
Trie node.
Extension
Trie extension node.
Implementations§
source§impl<K, V> Trie<K, V>
impl<K, V> Trie<K, V>
sourcepub fn leaf(key: K, value: V) -> Self
pub fn leaf(key: K, value: V) -> Self
Constructs a Trie::Leaf from a given key and value.
sourcepub fn node(indexed_pointers: &[(u8, Pointer)]) -> Self
pub fn node(indexed_pointers: &[(u8, Pointer)]) -> Self
Constructs a Trie::Node from a given slice of indexed pointers.
sourcepub fn extension(affix: Vec<u8>, pointer: Pointer) -> Self
pub fn extension(affix: Vec<u8>, pointer: Pointer) -> Self
Constructs a Trie::Extension from a given affix and pointer.
sourcepub fn trie_hash(&self) -> Result<Digest, Error>where
Self: ToBytes,
pub fn trie_hash(&self) -> Result<Digest, Error>where
Self: ToBytes,
Returns the hash of this Trie.
sourcepub fn as_pointer_block(&self) -> Option<&PointerBlock>
pub fn as_pointer_block(&self) -> Option<&PointerBlock>
Returns a pointer block, if possible.
sourcepub fn iter_children(&self) -> DescendantsIterator<'_> ⓘ
pub fn iter_children(&self) -> DescendantsIterator<'_> ⓘ
Returns an iterator over descendants of the trie.
Trait Implementations§
source§impl<'de, K, V> Deserialize<'de> for Trie<K, V>where
K: Deserialize<'de>,
V: Deserialize<'de>,
impl<'de, K, V> Deserialize<'de> for Trie<K, V>where
K: Deserialize<'de>,
V: Deserialize<'de>,
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<K: PartialEq, V: PartialEq> PartialEq for Trie<K, V>
impl<K: PartialEq, V: PartialEq> PartialEq for Trie<K, V>
source§impl<K, V> Store<Digest, Trie<K, V>> for InMemoryTrieStore
impl<K, V> Store<Digest, Trie<K, V>> for InMemoryTrieStore
source§fn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>
fn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>
Returns an optional value (may exist or not) as read through a transaction, or an error
of the associated
Self::Error variety.source§impl<K, V> Store<Digest, Trie<K, V>> for LmdbTrieStore
impl<K, V> Store<Digest, Trie<K, V>> for LmdbTrieStore
source§fn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>
fn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>
Returns an optional value (may exist or not) as read through a transaction, or an error
of the associated
Self::Error variety.source§impl<K, V> ToBytes for Trie<K, V>
impl<K, V> ToBytes for Trie<K, V>
source§fn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
Returns the length of the
Vec<u8> which would be returned from a successful call to
to_bytes() or into_bytes(). The data is not actually serialized, so this call is
relatively cheap.impl<K: Eq, V: Eq> Eq for Trie<K, V>
impl<K, V> StructuralPartialEq for Trie<K, V>
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for Trie<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Trie<K, V>
impl<K, V> Sync for Trie<K, V>
impl<K, V> Unpin for Trie<K, V>
impl<K, V> UnwindSafe for Trie<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.