[−][src]Trait reference_trie::NodeCodec
Trait for trie node encoding/decoding.
Associated Types
type Error: Error
Codec error type.
type HashOut: Clone + PartialEq<Self::HashOut> + Eq + AsRef<[u8]> + AsMut<[u8]> + Default + Send + Copy + Sync + Hash + MaybeDebug
Output type of encoded node hasher.
Required methods
fn hashed_null_node() -> Self::HashOut
Get the hashed null node.
fn decode_plan(data: &[u8]) -> Result<NodePlan, Self::Error>
Decode bytes to a NodePlan
. Returns Self::E
on failure.
fn is_empty_node(data: &[u8]) -> bool
Check if the provided bytes correspond to the codecs "empty" node.
fn empty_node() -> &'static [u8]
Returns an encoded empty node.
fn leaf_node(partial: ((u8, u8), &[u8]), value: &[u8]) -> Vec<u8>
Returns an encoded leaf node
fn extension_node(
partial: impl Iterator<Item = u8>,
number_nibble: usize,
child_ref: ChildReference<Self::HashOut>
) -> Vec<u8>
partial: impl Iterator<Item = u8>,
number_nibble: usize,
child_ref: ChildReference<Self::HashOut>
) -> Vec<u8>
Returns an encoded extension node
Note that number_nibble is the number of element of the iterator
it can possibly be obtain by Iterator
size_hint
, but
for simplicity it is used directly as a parameter.
fn branch_node(
children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
value: Option<&[u8]>
) -> Vec<u8>
children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
value: Option<&[u8]>
) -> Vec<u8>
Returns an encoded branch node.
Takes an iterator yielding ChildReference<Self::HashOut>
and an optional value.
fn branch_node_nibbled(
partial: impl Iterator<Item = u8>,
number_nibble: usize,
children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
value: Option<&[u8]>
) -> Vec<u8>
partial: impl Iterator<Item = u8>,
number_nibble: usize,
children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
value: Option<&[u8]>
) -> Vec<u8>
Returns an encoded branch node with a possible partial path.
number_nibble
is the partial path length as in extension_node
.
Provided methods
fn decode(data: &[u8]) -> Result<Node, Self::Error>
Decode bytes to a Node
. Returns Self::E
on failure.
Implementors
impl<H: Hasher> NodeCodec for ReferenceNodeCodec<H>
[src]
type Error = CodecError
type HashOut = H::Out
fn hashed_null_node() -> <H as Hasher>::Out
[src]
fn decode_plan(data: &[u8]) -> Result<NodePlan, Self::Error>
[src]
fn is_empty_node(data: &[u8]) -> bool
[src]
fn empty_node() -> &'static [u8]
[src]
fn leaf_node(partial: Partial, value: &[u8]) -> Vec<u8>
[src]
fn extension_node(
partial: impl Iterator<Item = u8>,
number_nibble: usize,
child: ChildReference<Self::HashOut>
) -> Vec<u8>
[src]
partial: impl Iterator<Item = u8>,
number_nibble: usize,
child: ChildReference<Self::HashOut>
) -> Vec<u8>
fn branch_node(
children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
maybe_value: Option<&[u8]>
) -> Vec<u8>
[src]
children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
maybe_value: Option<&[u8]>
) -> Vec<u8>
fn branch_node_nibbled(
_partial: impl Iterator<Item = u8>,
_number_nibble: usize,
_children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
_maybe_value: Option<&[u8]>
) -> Vec<u8>
[src]
_partial: impl Iterator<Item = u8>,
_number_nibble: usize,
_children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
_maybe_value: Option<&[u8]>
) -> Vec<u8>
impl<H: Hasher> NodeCodec for ReferenceNodeCodecNoExt<H>
[src]
type Error = CodecError
type HashOut = <H as Hasher>::Out
fn hashed_null_node() -> <H as Hasher>::Out
[src]
fn decode_plan(data: &[u8]) -> Result<NodePlan, Self::Error>
[src]
fn is_empty_node(data: &[u8]) -> bool
[src]
fn empty_node() -> &'static [u8]
[src]
fn leaf_node(partial: Partial, value: &[u8]) -> Vec<u8>
[src]
fn extension_node(
_partial: impl Iterator<Item = u8>,
_nbnibble: usize,
_child: ChildReference<<H as Hasher>::Out>
) -> Vec<u8>
[src]
_partial: impl Iterator<Item = u8>,
_nbnibble: usize,
_child: ChildReference<<H as Hasher>::Out>
) -> Vec<u8>
fn branch_node(
_children: impl Iterator<Item = impl Borrow<Option<ChildReference<<H as Hasher>::Out>>>>,
_maybe_value: Option<&[u8]>
) -> Vec<u8>
[src]
_children: impl Iterator<Item = impl Borrow<Option<ChildReference<<H as Hasher>::Out>>>>,
_maybe_value: Option<&[u8]>
) -> Vec<u8>
fn branch_node_nibbled(
partial: impl Iterator<Item = u8>,
number_nibble: usize,
children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
maybe_value: Option<&[u8]>
) -> Vec<u8>
[src]
partial: impl Iterator<Item = u8>,
number_nibble: usize,
children: impl Iterator<Item = impl Borrow<Option<ChildReference<Self::HashOut>>>>,
maybe_value: Option<&[u8]>
) -> Vec<u8>