[][src]Trait tari_mmr::ArrayLike

pub trait ArrayLike {
    type Value;
    type Error: Error;
    fn len(&self) -> usize;
fn push(&mut self, item: Self::Value) -> Result<usize, Self::Error>;
fn get(&self, index: usize) -> Option<&Self::Value>;
fn get_or_panic(&self, index: usize) -> &Self::Value; }

A trait describing generic array-like behaviour, without imposing any specific details on how this is actually done.

Associated Types

type Value

type Error: Error

Loading content...

Required methods

fn len(&self) -> usize

Returns the number of hashes stored in the backend

fn push(&mut self, item: Self::Value) -> Result<usize, Self::Error>

Store a new item and return the index of the stored item

fn get(&self, index: usize) -> Option<&Self::Value>

Return the item at the given index

fn get_or_panic(&self, index: usize) -> &Self::Value

Return the item at the given index. Use this if you know that the index is valid. Requesting a hash for an invalid index may cause the a panic

Loading content...

Implementations on Foreign Types

impl<T> ArrayLike for Vec<T>[src]

type Error = MerkleMountainRangeError

type Value = T

Loading content...

Implementors

Loading content...