Struct light_indexed_merkle_tree::array::IndexedArray
source · pub struct IndexedArray<H, I>where
H: Hasher,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned,
usize: From<I>,{
pub elements: Vec<IndexedElement<I>>,
pub current_node_index: I,
pub highest_element_index: I,
/* private fields */
}Fields§
§elements: Vec<IndexedElement<I>>§current_node_index: I§highest_element_index: IImplementations§
source§impl<H, I> IndexedArray<H, I>where
H: Hasher,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned,
usize: From<I>,
impl<H, I> IndexedArray<H, I>where
H: Hasher,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned,
usize: From<I>,
pub fn get(&self, index: usize) -> Option<&IndexedElement<I>>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> IndexingArrayIter<'_, H, I> ⓘ
pub fn find_element(&self, value: &BigUint) -> Option<&IndexedElement<I>>
pub fn init( &mut self, ) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>
sourcepub fn find_low_element_index_for_nonexistent(
&self,
value: &BigUint,
) -> Result<I, IndexedMerkleTreeError>
pub fn find_low_element_index_for_nonexistent( &self, value: &BigUint, ) -> Result<I, IndexedMerkleTreeError>
Returns the index of the low element for the given value, which is
not yet the part of the array.
Low element is the greatest element which still has lower value than the provided one.
Low elements are used in non-membership proofs.
sourcepub fn find_low_element_for_nonexistent(
&self,
value: &BigUint,
) -> Result<(IndexedElement<I>, BigUint), IndexedMerkleTreeError>
pub fn find_low_element_for_nonexistent( &self, value: &BigUint, ) -> Result<(IndexedElement<I>, BigUint), IndexedMerkleTreeError>
Returns the:
- Low element for the given value.
- Next value for that low element.
For the given value, which is not yet the part of the array.
Low element is the greatest element which still has lower value than the provided one.
Low elements are used in non-membership proofs.
sourcepub fn find_low_element_index_for_existent(
&self,
value: &BigUint,
) -> Result<I, IndexedMerkleTreeError>
pub fn find_low_element_index_for_existent( &self, value: &BigUint, ) -> Result<I, IndexedMerkleTreeError>
Returns the index of the low element for the given value, which is
already the part of the array.
Low element is the greatest element which still has lower value than the provided one.
Low elements are used in non-membership proofs.
sourcepub fn find_low_element_for_existent(
&self,
value: &BigUint,
) -> Result<IndexedElement<I>, IndexedMerkleTreeError>
pub fn find_low_element_for_existent( &self, value: &BigUint, ) -> Result<IndexedElement<I>, IndexedMerkleTreeError>
Returns the low element for the given value, which is already the
part of the array.
Low element is the greatest element which still has lower value than the provided one.
Low elements are used in non-membership proofs.
sourcepub fn hash_element(&self, index: I) -> Result<[u8; 32], IndexedMerkleTreeError>
pub fn hash_element(&self, index: I) -> Result<[u8; 32], IndexedMerkleTreeError>
Returns the hash of the given element. That hash consists of:
- The value of the given element.
- The
next_indexof the given element. - The value of the element pointed by
next_index.
sourcepub fn new_element_with_low_element_index(
&self,
low_element_index: I,
value: &BigUint,
) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>
pub fn new_element_with_low_element_index( &self, low_element_index: I, value: &BigUint, ) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>
Returns an updated low element and a new element, created based on the
provided low_element_index and value.
pub fn new_element( &self, value: &BigUint, ) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>
sourcepub fn append_with_low_element_index(
&mut self,
low_element_index: I,
value: &BigUint,
) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>
pub fn append_with_low_element_index( &mut self, low_element_index: I, value: &BigUint, ) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>
Appends the given value to the indexing array.
pub fn append( &mut self, value: &BigUint, ) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>
pub fn lowest(&self) -> Option<IndexedElement<I>>
Trait Implementations§
source§impl<H, I> Clone for IndexedArray<H, I>where
H: Hasher + Clone,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Clone,
usize: From<I>,
impl<H, I> Clone for IndexedArray<H, I>where
H: Hasher + Clone,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Clone,
usize: From<I>,
source§fn clone(&self) -> IndexedArray<H, I>
fn clone(&self) -> IndexedArray<H, I>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl<H, I> Debug for IndexedArray<H, I>where
H: Hasher + Debug,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Debug,
usize: From<I>,
impl<H, I> Debug for IndexedArray<H, I>where
H: Hasher + Debug,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned + Debug,
usize: From<I>,
source§impl<H, I> Default for IndexedArray<H, I>where
H: Hasher,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned,
usize: From<I>,
impl<H, I> Default for IndexedArray<H, I>where
H: Hasher,
I: CheckedAdd + CheckedSub + Copy + Clone + PartialOrd + ToBytes + TryFrom<usize> + Unsigned,
usize: From<I>,
Auto Trait Implementations§
impl<H, I> Freeze for IndexedArray<H, I>
impl<H, I> RefUnwindSafe for IndexedArray<H, I>
impl<H, I> Send for IndexedArray<H, I>
impl<H, I> Sync for IndexedArray<H, I>
impl<H, I> Unpin for IndexedArray<H, I>
impl<H, I> UnwindSafe for IndexedArray<H, I>
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more