Struct IndexedArray

Source
pub struct IndexedArray<H, 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: I

Implementations§

Source§

impl<H, I> IndexedArray<H, I>

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>

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>>

Trait Implementations§

Source§

impl<H, I> Clone for IndexedArray<H, I>

Source§

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

Returns a duplicate 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> Debug for IndexedArray<H, I>

Source§

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

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

impl<H, I> Default for IndexedArray<H, I>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

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

§

impl<H, I> RefUnwindSafe for IndexedArray<H, I>

§

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

§

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

§

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

§

impl<H, I> UnwindSafe for IndexedArray<H, I>

Blanket Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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