Struct saito_rust::crypto::MerkleTree [−]
pub struct MerkleTree<T> {
pub algorithm: &'static Algorithm,
// some fields omitted
}
Expand description
A Merkle tree is a binary tree, with values of type T
at the leafs,
and where every internal node holds the hash of the concatenation of the hashes of its children nodes.
Fields
algorithm: &'static Algorithm
The hashing algorithm used by this Merkle tree
Implementations
impl<T> MerkleTree<T>
impl<T> MerkleTree<T>
pub fn from_vec(
algorithm: &'static Algorithm,
values: Vec<T, Global>
) -> MerkleTree<T> where
T: Hashable,
pub fn from_vec(
algorithm: &'static Algorithm,
values: Vec<T, Global>
) -> MerkleTree<T> where
T: Hashable,
Constructs a Merkle Tree from a vector of data blocks.
Returns None
if values
is empty.
Returns the root hash of Merkle tree
Generate an inclusion proof for the given value.
Returns None
if the given value is not found in the tree.
pub fn gen_nth_proof(&self, n: usize) -> Option<Proof<T>> where
T: Hashable + Clone,
pub fn gen_nth_proof(&self, n: usize) -> Option<Proof<T>> where
T: Hashable + Clone,
Generate an inclusion proof for the n
-th leaf value.
pub fn iter(&self) -> LeavesIterator<'_, T>
pub fn iter(&self) -> LeavesIterator<'_, T>
Creates an Iterator
over the values contained in this Merkle tree.
Trait Implementations
impl<T> Clone for MerkleTree<T> where
T: Clone,
impl<T> Clone for MerkleTree<T> where
T: Clone,
pub fn clone(&self) -> MerkleTree<T>
pub fn clone(&self) -> MerkleTree<T>
Returns a copy of the value. Read more
Performs copy-assignment from source
. Read more
impl<T> Debug for MerkleTree<T> where
T: Debug,
impl<T> Debug for MerkleTree<T> where
T: Debug,
impl<T> Hash for MerkleTree<T> where
T: Hash,
impl<T> Hash for MerkleTree<T> where
T: Hash,
impl<'a, T> IntoIterator for &'a MerkleTree<T>
impl<'a, T> IntoIterator for &'a MerkleTree<T>
pub fn into_iter(self) -> <&'a MerkleTree<T> as IntoIterator>::IntoIter
pub fn into_iter(self) -> <&'a MerkleTree<T> as IntoIterator>::IntoIter
Creates a borrowing Iterator
over the values contained in this Merkle tree.
type IntoIter = LeavesIterator<'a, T>
type IntoIter = LeavesIterator<'a, T>
Which kind of iterator are we turning this into?
impl<T> IntoIterator for MerkleTree<T>
impl<T> IntoIterator for MerkleTree<T>
pub fn into_iter(self) -> <MerkleTree<T> as IntoIterator>::IntoIter
pub fn into_iter(self) -> <MerkleTree<T> as IntoIterator>::IntoIter
Creates a consuming iterator, that is, one that moves each value out of the Merkle tree. The tree cannot be used after calling this.
type Item = T
type Item = T
The type of the elements being iterated over.
type IntoIter = LeavesIntoIterator<T>
type IntoIter = LeavesIntoIterator<T>
Which kind of iterator are we turning this into?
impl<T> Ord for MerkleTree<T> where
T: Ord,
impl<T> Ord for MerkleTree<T> where
T: Ord,
pub fn cmp(&self, other: &MerkleTree<T>) -> Ordering
pub fn cmp(&self, other: &MerkleTree<T>) -> Ordering
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
impl<T> PartialEq<MerkleTree<T>> for MerkleTree<T> where
T: PartialEq<T>,
impl<T> PartialEq<MerkleTree<T>> for MerkleTree<T> where
T: PartialEq<T>,
impl<T> PartialOrd<MerkleTree<T>> for MerkleTree<T> where
T: Ord,
impl<T> PartialOrd<MerkleTree<T>> for MerkleTree<T> where
T: Ord,
pub fn partial_cmp(&self, other: &MerkleTree<T>) -> Option<Ordering>
pub fn partial_cmp(&self, other: &MerkleTree<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
impl<T> Eq for MerkleTree<T> where
T: Eq,
Auto Trait Implementations
impl<T> RefUnwindSafe for MerkleTree<T> where
T: RefUnwindSafe,
impl<T> Send for MerkleTree<T> where
T: Send,
impl<T> Sync for MerkleTree<T> where
T: Sync,
impl<T> Unpin for MerkleTree<T> where
T: Unpin,
impl<T> UnwindSafe for MerkleTree<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more