Struct light_indexed_merkle_tree::array::IndexedArray

source ·
pub struct IndexedArray<H, I, const ELEMENTS: usize>{
    pub elements: [IndexedElement<I>; ELEMENTS],
    pub current_node_index: I,
    pub highest_element_index: I,
    /* private fields */
}

Fields§

§elements: [IndexedElement<I>; ELEMENTS]§current_node_index: I§highest_element_index: I

Implementations§

source§

impl<H, I, const ELEMENTS: usize> IndexedArray<H, I, ELEMENTS>

source

pub fn get(&self, index: usize) -> Option<&IndexedElement<I>>

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn iter(&self) -> IndexingArrayIter<'_, H, I, ELEMENTS>

source

pub fn find_element(&self, value: &BigUint) -> Option<&IndexedElement<I>>

source

pub fn init( &mut self, ) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>

source

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.

source

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.

source

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.

source

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.

source

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_index of the given element.
  • The value of the element pointed by next_index.
source

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.

source

pub fn new_element( &self, value: &BigUint, ) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>

source

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.

source

pub fn append( &mut self, value: &BigUint, ) -> Result<IndexedElementBundle<I>, IndexedMerkleTreeError>

source

pub fn lowest(&self) -> Option<IndexedElement<I>>

source

pub fn dequeue_at_with_low_element_index( &mut self, low_element_index: I, index: I, ) -> Result<Option<IndexedElement<I>>, IndexedMerkleTreeError>

Returns and removes the element from the given index.

It also performs necessary updated of the remaning elements, to preserve the integrity of the array.

The low element under low_element_index is updated, to point to a new next element instead of the one which is removed.

source

pub fn dequeue_at( &mut self, index: I, ) -> Result<Option<IndexedElement<I>>, IndexedMerkleTreeError>

Returns and removes the element from the given index.

It also performs necessary updates of the remaning elements, to preserve the integrity of the array. It searches for the low element and updates it, to point to a new next element instead of the one

Trait Implementations§

source§

impl<H, I, const ELEMENTS: usize> Clone for IndexedArray<H, I, ELEMENTS>

source§

fn clone(&self) -> IndexedArray<H, I, ELEMENTS>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<H, I, const ELEMENTS: usize> Debug for IndexedArray<H, I, ELEMENTS>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<H, I, const ELEMENTS: usize> Default for IndexedArray<H, I, ELEMENTS>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<H, I, const ELEMENTS: usize> Freeze for IndexedArray<H, I, ELEMENTS>
where usize: Sized, I: Freeze,

§

impl<H, I, const ELEMENTS: usize> RefUnwindSafe for IndexedArray<H, I, ELEMENTS>

§

impl<H, I, const ELEMENTS: usize> Send for IndexedArray<H, I, ELEMENTS>
where usize: Sized, I: Send, H: Send,

§

impl<H, I, const ELEMENTS: usize> Sync for IndexedArray<H, I, ELEMENTS>
where usize: Sized, I: Sync, H: Sync,

§

impl<H, I, const ELEMENTS: usize> Unpin for IndexedArray<H, I, ELEMENTS>
where usize: Sized, I: Unpin, H: Unpin,

§

impl<H, I, const ELEMENTS: usize> UnwindSafe for IndexedArray<H, I, ELEMENTS>

Blanket Implementations§

source§

impl<T> AbiExample for T

source§

default fn example() -> T

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V