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 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<Trie<K, V>> for Trie<K, V>
impl<K: PartialEq, V: PartialEq> PartialEq<Trie<K, V>> 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>where
T: Readable<Handle = Self::Handle>,
K: AsRef<[u8]>,
Self::Error: From<T::Error>,
fn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>where T: Readable<Handle = Self::Handle>, K: AsRef<[u8]>, Self::Error: From<T::Error>,
Returns an optional value (may exist or not) as read through a transaction, or an error
of the associated
Self::Error
variety.source§fn put_raw<T>(
&self,
txn: &mut T,
key: &K,
value_bytes: Cow<'_, [u8]>
) -> Result<(), Self::Error>where
T: Writable<Handle = Self::Handle>,
K: AsRef<[u8]>,
Self::Error: From<T::Error>,
fn put_raw<T>( &self, txn: &mut T, key: &K, value_bytes: Cow<'_, [u8]> ) -> Result<(), Self::Error>where T: Writable<Handle = Self::Handle>, K: AsRef<[u8]>, Self::Error: From<T::Error>,
Puts a raw
value
into the store at key
within a transaction, potentially returning an
error of type Self::Error
if that fails. Read moresource§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>where
T: Readable<Handle = Self::Handle>,
K: AsRef<[u8]>,
Self::Error: From<T::Error>,
fn get_raw<T>(&self, txn: &T, key: &K) -> Result<Option<Bytes>, Self::Error>where T: Readable<Handle = Self::Handle>, K: AsRef<[u8]>, Self::Error: From<T::Error>,
Returns an optional value (may exist or not) as read through a transaction, or an error
of the associated
Self::Error
variety.source§fn put_raw<T>(
&self,
txn: &mut T,
key: &K,
value_bytes: Cow<'_, [u8]>
) -> Result<(), Self::Error>where
T: Writable<Handle = Self::Handle>,
K: AsRef<[u8]>,
Self::Error: From<T::Error>,
fn put_raw<T>( &self, txn: &mut T, key: &K, value_bytes: Cow<'_, [u8]> ) -> Result<(), Self::Error>where T: Writable<Handle = Self::Handle>, K: AsRef<[u8]>, Self::Error: From<T::Error>,
Puts a raw
value
into the store at key
within a transaction, potentially returning an
error of type Self::Error
if that fails. Read moresource§impl<K, V> ToBytes for Trie<K, V>where
K: ToBytes,
V: ToBytes,
impl<K, V> ToBytes for Trie<K, V>where K: ToBytes, V: ToBytes,
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> StructuralEq 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>where K: Send, V: Send,
impl<K, V> Sync for Trie<K, V>where K: Sync, V: Sync,
impl<K, V> Unpin for Trie<K, V>where K: Unpin, V: Unpin,
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> Conv for T
impl<T> Conv for T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
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 + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
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.source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for T
impl<T> Pipe for T
§impl<T> PipeAsRef for T
impl<T> PipeAsRef for T
§impl<T> PipeBorrow for T
impl<T> PipeBorrow for T
§impl<T> PipeDeref for T
impl<T> PipeDeref for T
§impl<T> PipeRef for T
impl<T> PipeRef for T
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
Pipes a reference into a function that cannot ordinarily be called in
suffix position. Read more
§fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
Pipes a mutable reference into a function that cannot ordinarily be
called in suffix position. Read more
§impl<T> Tap for T
impl<T> Tap for T
§fn tap<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
fn tap<F, R>(self, func: F) -> Selfwhere F: FnOnce(&Self) -> R,
Provides immutable access for inspection. Read more
§fn tap_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Selfwhere F: FnOnce(&Self) -> R,
Calls
tap
in debug builds, and does nothing in release builds.§fn tap_mut<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Selfwhere F: FnOnce(&mut Self) -> R,
Provides mutable access for modification. Read more
§fn tap_mut_dbg<F, R>(self, func: F) -> Selfwhere
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Selfwhere F: FnOnce(&mut Self) -> R,
Calls
tap_mut
in debug builds, and does nothing in release builds.§impl<T, U> TapAsRef<U> for Twhere
U: ?Sized,
impl<T, U> TapAsRef<U> for Twhere U: ?Sized,
§fn tap_ref<F, R>(self, func: F) -> Selfwhere
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref<F, R>(self, func: F) -> Selfwhere Self: AsRef<T>, F: FnOnce(&T) -> R,
Provides immutable access to the reference for inspection.
§fn tap_ref_dbg<F, R>(self, func: F) -> Selfwhere
Self: AsRef<T>,
F: FnOnce(&T) -> R,
fn tap_ref_dbg<F, R>(self, func: F) -> Selfwhere Self: AsRef<T>, F: FnOnce(&T) -> R,
Calls
tap_ref
in debug builds, and does nothing in release builds.§fn tap_ref_mut<F, R>(self, func: F) -> Selfwhere
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut<F, R>(self, func: F) -> Selfwhere Self: AsMut<T>, F: FnOnce(&mut T) -> R,
Provides mutable access to the reference for modification.
§fn tap_ref_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: AsMut<T>, F: FnOnce(&mut T) -> R,
Calls
tap_ref_mut
in debug builds, and does nothing in release builds.§impl<T, U> TapBorrow<U> for Twhere
U: ?Sized,
impl<T, U> TapBorrow<U> for Twhere U: ?Sized,
§fn tap_borrow<F, R>(self, func: F) -> Selfwhere
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow<F, R>(self, func: F) -> Selfwhere Self: Borrow<T>, F: FnOnce(&T) -> R,
Provides immutable access to the borrow for inspection. Read more
§fn tap_borrow_dbg<F, R>(self, func: F) -> Selfwhere
Self: Borrow<T>,
F: FnOnce(&T) -> R,
fn tap_borrow_dbg<F, R>(self, func: F) -> Selfwhere Self: Borrow<T>, F: FnOnce(&T) -> R,
Calls
tap_borrow
in debug builds, and does nothing in release builds.§fn tap_borrow_mut<F, R>(self, func: F) -> Selfwhere
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Selfwhere Self: BorrowMut<T>, F: FnOnce(&mut T) -> R,
Provides mutable access to the borrow for modification.
§fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: BorrowMut<T>, F: FnOnce(&mut T) -> R,
Calls
tap_borrow_mut
in debug builds, and does nothing in release
builds.§impl<T> TapDeref for T
impl<T> TapDeref for T
§fn tap_deref<F, R>(self, func: F) -> Selfwhere
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref<F, R>(self, func: F) -> Selfwhere Self: Deref, F: FnOnce(&Self::Target) -> R,
Immutably dereferences
self
for inspection.§fn tap_deref_dbg<F, R>(self, func: F) -> Selfwhere
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Selfwhere Self: Deref, F: FnOnce(&Self::Target) -> R,
Calls
tap_deref
in debug builds, and does nothing in release builds.§fn tap_deref_mut<F, R>(self, func: F) -> Selfwhere
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Selfwhere Self: DerefMut, F: FnOnce(&mut Self::Target) -> R,
Mutably dereferences
self
for modification.§fn tap_deref_mut_dbg<F, R>(self, func: F) -> Selfwhere
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Selfwhere Self: DerefMut, F: FnOnce(&mut Self::Target) -> R,
Calls
tap_deref_mut
in debug builds, and does nothing in release
builds.