Struct dusk_poseidon::tree::PoseidonTree
source · [−]pub struct PoseidonTree<L, A, const DEPTH: usize> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>, { /* private fields */ }
Expand description
Represents a Merkle Tree with a given depth that will be calculated using the Poseidon Hash technique.
Implementations
sourceimpl<L, A, const DEPTH: usize> PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
impl<L, A, const DEPTH: usize> PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
sourcepub fn push(&mut self, leaf: L) -> Result<u64, Error>
pub fn push(&mut self, leaf: L) -> Result<u64, Error>
Append a leaf to the tree. Return the index of the appended leaf.
sourcepub fn pop(&mut self) -> Result<Option<L>, Error>
pub fn pop(&mut self) -> Result<Option<L>, Error>
Fetch, remove and return the last inserted leaf, if present.
sourcepub fn branch(&self, n: u64) -> Result<Option<PoseidonBranch<DEPTH>>, Error>
pub fn branch(&self, n: u64) -> Result<Option<PoseidonBranch<DEPTH>>, Error>
Return a full merkle opening for this poseidon tree for a given index.
sourcepub fn iter_walk(
&self,
start: u64
) -> Result<impl IntoIterator<Item = Result<&L, CanonError>>, Error>
pub fn iter_walk(
&self,
start: u64
) -> Result<impl IntoIterator<Item = Result<&L, CanonError>>, Error>
Provides an iterator over the leaves of the tree from a provided starting point.
To iterate the entire tree, simply provide 0
as start
.
sourcepub fn annotated_iter_walk<W>(
&self,
walker: W
) -> Result<impl IntoIterator<Item = Result<&L, CanonError>>, Error> where
W: Walker<NStack<L, A>, A>,
pub fn annotated_iter_walk<W>(
&self,
walker: W
) -> Result<impl IntoIterator<Item = Result<&L, CanonError>>, Error> where
W: Walker<NStack<L, A>, A>,
Provides an iterator over the leaves of the tree which have been previously annotated via a custom Walker
passed
as argument.
Note
This is only useful if annotate the tree is going to make the iteration perform sub-linearly.
Trait Implementations
sourceimpl<L, A, const DEPTH: usize> AsMut<NStack<L, A>> for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
impl<L, A, const DEPTH: usize> AsMut<NStack<L, A>> for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
sourceimpl<L, A, const DEPTH: usize> AsRef<NStack<L, A>> for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
impl<L, A, const DEPTH: usize> AsRef<NStack<L, A>> for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
sourceimpl<L: Canon, A: Canon, const DEPTH: usize> Canon for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
impl<L: Canon, A: Canon, const DEPTH: usize> Canon for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
sourceimpl<L: Clone, A: Clone, const DEPTH: usize> Clone for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
impl<L: Clone, A: Clone, const DEPTH: usize> Clone for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
sourcefn clone(&self) -> PoseidonTree<L, A, DEPTH>
fn clone(&self) -> PoseidonTree<L, A, DEPTH>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<L: Debug, A: Debug, const DEPTH: usize> Debug for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
impl<L: Debug, A: Debug, const DEPTH: usize> Debug for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
sourceimpl<L, A, const DEPTH: usize> Default for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
impl<L, A, const DEPTH: usize> Default for PoseidonTree<L, A, DEPTH> where
L: PoseidonLeaf,
A: PoseidonTreeAnnotation<L>,
Auto Trait Implementations
impl<L, A, const DEPTH: usize> !RefUnwindSafe for PoseidonTree<L, A, DEPTH>
impl<L, A, const DEPTH: usize> Send for PoseidonTree<L, A, DEPTH> where
A: Send + Sync,
L: Send + Sync,
impl<L, A, const DEPTH: usize> Sync for PoseidonTree<L, A, DEPTH> where
A: Send + Sync,
L: Send + Sync,
impl<L, A, const DEPTH: usize> Unpin for PoseidonTree<L, A, DEPTH> where
A: Unpin,
L: Unpin,
impl<L, A, const DEPTH: usize> !UnwindSafe for PoseidonTree<L, A, DEPTH>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> EncodeToVec for T where
T: Canon,
impl<T> EncodeToVec for T where
T: Canon,
sourcefn encode_to_vec(&self) -> Vec<u8, Global>
fn encode_to_vec(&self) -> Vec<u8, Global>
Encode Self
into a buffer
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more