Struct sp_trie::NodeCodec

source ·
pub struct NodeCodec<H>(/* private fields */);
Expand description

The Substrate format implementation of NodeCodec. Concrete implementation of a NodeCodecT with SCALE encoding.

It is generic over H the Hasher.

Trait Implementations§

source§

impl<H: Clone> Clone for NodeCodec<H>

source§

fn clone(&self) -> NodeCodec<H>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<H: Default> Default for NodeCodec<H>

source§

fn default() -> NodeCodec<H>

Returns the “default value” for a type. Read more
source§

impl<H> NodeCodec for NodeCodec<H>where H: Hasher,

source§

const ESCAPE_HEADER: Option<u8> = _

Escape header byte sequence to indicate next node is a branch or leaf with hash of value, followed by the value node.
§

type Error = Error<<H as Hasher>::Out>

Codec error type.
§

type HashOut = <H as Hasher>::Out

Output type of encoded node hasher.
source§

fn hashed_null_node() -> <H as Hasher>::Out

Get the hashed null node.
source§

fn decode_plan(data: &[u8]) -> Result<NodePlan, Self::Error>

Decode bytes to a NodePlan. Returns Self::E on failure.
source§

fn is_empty_node(data: &[u8]) -> bool

Check if the provided bytes correspond to the codecs “empty” node.
source§

fn empty_node() -> &'static [u8]

Returns an encoded empty node.
source§

fn leaf_node( partial: impl Iterator<Item = u8>, number_nibble: usize, value: Value<'_> ) -> Vec<u8>

Returns an encoded leaf node Read more
source§

fn extension_node( _partial: impl Iterator<Item = u8>, _nbnibble: usize, _child: ChildReference<<H as Hasher>::Out> ) -> Vec<u8>

Returns an encoded extension node Read more
source§

fn branch_node( _children: impl Iterator<Item = impl Borrow<Option<ChildReference<<H as Hasher>::Out>>>>, _maybe_value: Option<Value<'_>> ) -> Vec<u8>

Returns an encoded branch node. Takes an iterator yielding ChildReference<Self::HashOut> and an optional value.
source§

fn branch_node_nibbled( partial: impl Iterator<Item = u8>, number_nibble: usize, children: impl Iterator<Item = impl Borrow<Option<ChildReference<<H as Hasher>::Out>>>>, value: Option<Value<'_>> ) -> Vec<u8>

Returns an encoded branch node with a possible partial path. number_nibble is the partial path length as in extension_node.
source§

fn decode<'a>(data: &'a [u8]) -> Result<Node<'a>, Self::Error>

Decode bytes to a Node. Returns Self::E on failure.
source§

impl<'a, H: Hasher> TrieCache<NodeCodec<H>> for TrieCache<'a, H>

source§

fn get_or_insert_node( &mut self, hash: H::Out, fetch_node: &mut dyn FnMut() -> Result<NodeOwned<H::Out>, H::Out, Error<H::Out>> ) -> Result<&NodeOwned<H::Out>, H::Out, Error<H::Out>>

Get or insert a NodeOwned. Read more
source§

fn get_node(&mut self, hash: &H::Out) -> Option<&NodeOwned<H::Out>>

Get the NodeOwned that corresponds to the given hash.
source§

fn lookup_value_for_key(&mut self, key: &[u8]) -> Option<&CachedValue<H::Out>>

Lookup value for the given key. Read more
source§

fn cache_value_for_key(&mut self, key: &[u8], data: CachedValue<H::Out>)

Cache the given value for the given key. Read more

Auto Trait Implementations§

§

impl<H> RefUnwindSafe for NodeCodec<H>where H: RefUnwindSafe,

§

impl<H> Send for NodeCodec<H>where H: Send,

§

impl<H> Sync for NodeCodec<H>where H: Sync,

§

impl<H> Unpin for NodeCodec<H>where H: Unpin,

§

impl<H> UnwindSafe for NodeCodec<H>where H: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, Outer> IsWrappedBy<Outer> for Twhere Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

source§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

source§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<S, T> UncheckedInto<T> for Swhere T: UncheckedFrom<S>,

source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> JsonSchemaMaybe for T

§

impl<T> MaybeRefUnwindSafe for Twhere T: RefUnwindSafe,