miden_crypto::merkle

Enum SmtLeaf

source
pub enum SmtLeaf {
    Empty(LeafIndex<SMT_DEPTH>),
    Single((RpoDigest, Word)),
    Multiple(Vec<(RpoDigest, Word)>),
}

Variants§

§

Empty(LeafIndex<SMT_DEPTH>)

§

Single((RpoDigest, Word))

§

Multiple(Vec<(RpoDigest, Word)>)

Implementations§

source§

impl SmtLeaf

source

pub fn new( entries: Vec<(RpoDigest, Word)>, leaf_index: LeafIndex<SMT_DEPTH>, ) -> Result<Self, SmtLeafError>

Returns a new leaf with the specified entries

§Errors
  • Returns an error if 2 keys in entries map to a different leaf index
  • Returns an error if 1 or more keys in entries map to a leaf index different from leaf_index
source

pub fn new_empty(leaf_index: LeafIndex<SMT_DEPTH>) -> Self

Returns a new empty leaf with the specified leaf index

source

pub fn new_single(key: RpoDigest, value: Word) -> Self

Returns a new single leaf with the specified entry. The leaf index is derived from the entry’s key.

source

pub fn new_multiple( entries: Vec<(RpoDigest, Word)>, ) -> Result<Self, SmtLeafError>

Returns a new single leaf with the specified entry. The leaf index is derived from the entries’ keys.

§Errors
  • Returns an error if 2 keys in entries map to a different leaf index
source

pub fn is_empty(&self) -> bool

Returns true if the leaf is empty

source

pub fn index(&self) -> LeafIndex<SMT_DEPTH>

Returns the leaf’s index in the super::Smt

source

pub fn num_entries(&self) -> u64

Returns the number of entries stored in the leaf

source

pub fn hash(&self) -> RpoDigest

Computes the hash of the leaf

source

pub fn entries(&self) -> Vec<&(RpoDigest, Word)>

Returns the key-value pairs in the leaf

source

pub fn to_elements(&self) -> Vec<Felt>

Converts a leaf to a list of field elements

source

pub fn into_elements(self) -> Vec<Felt>

Converts a leaf to a list of field elements

source

pub fn into_entries(self) -> Vec<(RpoDigest, Word)>

Converts a leaf the key-value pairs in the leaf

Trait Implementations§

source§

impl Clone for SmtLeaf

source§

fn clone(&self) -> SmtLeaf

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

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

Performs copy-assignment from source. Read more
source§

impl Debug for SmtLeaf

source§

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

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

impl Deserializable for SmtLeaf

source§

fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result. Read more
source§

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
source§

impl PartialEq for SmtLeaf

source§

fn eq(&self, other: &SmtLeaf) -> bool

Tests for self and other values to be equal, and is used by ==.
1.6.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serializable for SmtLeaf

source§

fn write_into<W: ByteWriter>(&self, target: &mut W)

Serializes self into bytes and writes these bytes into the target.
source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
source§

impl Eq for SmtLeaf

source§

impl StructuralPartialEq for SmtLeaf

Auto Trait Implementations§

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, dst: *mut T)

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