Trait patricia_trie::NodeCodec [−][src]
pub trait NodeCodec<H: Hasher>: Sized { type Error: Error; const HASHED_NULL_NODE: H::Out; fn decode(data: &[u8]) -> Result<Node, Self::Error>; fn try_decode_hash(data: &[u8]) -> Option<H::Out>; fn is_empty_node(data: &[u8]) -> bool; fn empty_node() -> ElasticArray1024<u8>; fn leaf_node(partial: &[u8], value: &[u8]) -> ElasticArray1024<u8>; fn ext_node(
partial: &[u8],
child_ref: ChildReference<H::Out>
) -> ElasticArray1024<u8>; fn branch_node<I>(
children: I,
value: Option<ElasticArray128<u8>>
) -> ElasticArray1024<u8>
where
I: IntoIterator<Item = Option<ChildReference<H::Out>>>; }
Trait for trie node encoding/decoding
Associated Types
Associated Constants
const HASHED_NULL_NODE: H::Out
Null node type
Required Methods
fn decode(data: &[u8]) -> Result<Node, Self::Error>
Decode bytes to a Node
. Returns Self::E
on failure.
fn try_decode_hash(data: &[u8]) -> Option<H::Out>
Decode bytes to the Hasher
s output type. Returns None
on failure.
fn is_empty_node(data: &[u8]) -> bool
Check if the provided bytes correspond to the codecs "empty" node.
fn empty_node() -> ElasticArray1024<u8>
Returns an empty node
fn leaf_node(partial: &[u8], value: &[u8]) -> ElasticArray1024<u8>
Returns an encoded leaft node
fn ext_node(
partial: &[u8],
child_ref: ChildReference<H::Out>
) -> ElasticArray1024<u8>
partial: &[u8],
child_ref: ChildReference<H::Out>
) -> ElasticArray1024<u8>
Returns an encoded extension node
fn branch_node<I>(
children: I,
value: Option<ElasticArray128<u8>>
) -> ElasticArray1024<u8> where
I: IntoIterator<Item = Option<ChildReference<H::Out>>>,
children: I,
value: Option<ElasticArray128<u8>>
) -> ElasticArray1024<u8> where
I: IntoIterator<Item = Option<ChildReference<H::Out>>>,
Returns an encoded branch node. Takes an iterator yielding ChildReference<H::Out>
and an optional value