pub trait Version {
    type NodeData: Debug;

    // Required methods
    fn consensus_branch_id(data: &Self::NodeData) -> u32;
    fn start_height(data: &Self::NodeData) -> u64;
    fn end_height(data: &Self::NodeData) -> u64;
    fn combine_inner(
        subtree_commitment: [u8; 32],
        left: &Self::NodeData,
        right: &Self::NodeData
    ) -> Self::NodeData;
    fn read<R: Read>(
        consensus_branch_id: u32,
        r: &mut R
    ) -> Result<Self::NodeData>;
    fn write<W: Write>(data: &Self::NodeData, w: &mut W) -> Result<()>;

    // Provided methods
    fn combine(left: &Self::NodeData, right: &Self::NodeData) -> Self::NodeData { ... }
    fn to_bytes(data: &Self::NodeData) -> Vec<u8> { ... }
    fn from_bytes<T: AsRef<[u8]>>(
        consensus_branch_id: u32,
        buf: T
    ) -> Result<Self::NodeData> { ... }
    fn hash(data: &Self::NodeData) -> [u8; 32] { ... }
}
Expand description

A version of the chain history tree.

Required Associated Types§

source

type NodeData: Debug

The node data for this tree version.

Required Methods§

source

fn consensus_branch_id(data: &Self::NodeData) -> u32

Returns the consensus branch ID for the given node data.

source

fn start_height(data: &Self::NodeData) -> u64

Returns the start height for the given node data.

source

fn end_height(data: &Self::NodeData) -> u64

Returns the end height for the given node data.

source

fn combine_inner( subtree_commitment: [u8; 32], left: &Self::NodeData, right: &Self::NodeData ) -> Self::NodeData

Combines two nodes metadata.

For internal use.

source

fn read<R: Read>(consensus_branch_id: u32, r: &mut R) -> Result<Self::NodeData>

Parses node data from the given reader.

source

fn write<W: Write>(data: &Self::NodeData, w: &mut W) -> Result<()>

Writes the byte representation of the given node data to the given writer.

Provided Methods§

source

fn combine(left: &Self::NodeData, right: &Self::NodeData) -> Self::NodeData

Combines two nodes’ metadata.

source

fn to_bytes(data: &Self::NodeData) -> Vec<u8>

Converts to byte representation.

source

fn from_bytes<T: AsRef<[u8]>>( consensus_branch_id: u32, buf: T ) -> Result<Self::NodeData>

Convert from byte representation.

source

fn hash(data: &Self::NodeData) -> [u8; 32]

Hash node metadata

Object Safety§

This trait is not object safe.

Implementors§