pub struct MerkleTree { /* private fields */ }Expand description
A Merkle tree for content blocks.
Merkle trees enable efficient verification of content integrity and support selective disclosure proofs.
Implementations§
Source§impl MerkleTree
impl MerkleTree
Sourcepub fn from_items<T: AsRef<[u8]>>(
items: &[T],
algorithm: HashAlgorithm,
) -> Result<Self>
pub fn from_items<T: AsRef<[u8]>>( items: &[T], algorithm: HashAlgorithm, ) -> Result<Self>
Sourcepub fn from_hashes(
hashes: &[DocumentId],
algorithm: HashAlgorithm,
) -> Result<Self>
pub fn from_hashes( hashes: &[DocumentId], algorithm: HashAlgorithm, ) -> Result<Self>
Sourcepub fn root_hash(&self) -> &DocumentId
pub fn root_hash(&self) -> &DocumentId
Get the root hash of the tree.
Sourcepub fn root(&self) -> &MerkleNode
pub fn root(&self) -> &MerkleNode
Get the root node.
Sourcepub fn algorithm(&self) -> HashAlgorithm
pub fn algorithm(&self) -> HashAlgorithm
Get the hash algorithm used.
Sourcepub fn leaf_count(&self) -> usize
pub fn leaf_count(&self) -> usize
Get the number of leaf nodes.
Trait Implementations§
Source§impl Clone for MerkleTree
impl Clone for MerkleTree
Source§fn clone(&self) -> MerkleTree
fn clone(&self) -> MerkleTree
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MerkleTree
impl Debug for MerkleTree
Source§impl<'de> Deserialize<'de> for MerkleTree
impl<'de> Deserialize<'de> for MerkleTree
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for MerkleTree
impl PartialEq for MerkleTree
Source§impl Serialize for MerkleTree
impl Serialize for MerkleTree
impl Eq for MerkleTree
impl StructuralPartialEq for MerkleTree
Auto Trait Implementations§
impl Freeze for MerkleTree
impl RefUnwindSafe for MerkleTree
impl Send for MerkleTree
impl Sync for MerkleTree
impl Unpin for MerkleTree
impl UnsafeUnpin for MerkleTree
impl UnwindSafe for MerkleTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.