pub trait MerkleTree: Sectored {
    // Required methods
    fn assert_root_contains(&mut self, hash_data: Option<&[u8]>) -> Result<()>;
    fn write(&mut self, offset: usize, data: &[u8]) -> Result<()>;
    fn verify(&self, offset: usize, data: &[u8]) -> Result<()>;
    fn root_hash(&self) -> Result<&[u8]>;
}

Required Methods§

source

fn assert_root_contains(&mut self, hash_data: Option<&[u8]>) -> Result<()>

Checks that the root node contains the given hash data. If it does then Ok(()) is returned. If it doesn’t, then Err(Error::HashCmpFailure) is returned.

source

fn write(&mut self, offset: usize, data: &[u8]) -> Result<()>

Hashes the given data, adds a new node to the tree with its hash and updates the hashes of all parent nodes.

source

fn verify(&self, offset: usize, data: &[u8]) -> Result<()>

Verifies that the given data stored from the given offset into the protected data, has not been modified.

source

fn root_hash(&self) -> Result<&[u8]>

Returns the hash data stored in the root node of the tree. An error is returned if and only if the tree is empty.

Implementors§