pub enum SmtLeaf {
Empty(LeafIndex<SMT_DEPTH>),
Single((RpoDigest, Word)),
Multiple(Vec<(RpoDigest, Word)>),
}
Variants§
Implementations§
source§impl SmtLeaf
impl SmtLeaf
sourcepub fn new(
entries: Vec<(RpoDigest, Word)>,
leaf_index: LeafIndex<SMT_DEPTH>,
) -> Result<Self, SmtLeafError>
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 fromleaf_index
sourcepub fn new_empty(leaf_index: LeafIndex<SMT_DEPTH>) -> Self
pub fn new_empty(leaf_index: LeafIndex<SMT_DEPTH>) -> Self
Returns a new empty leaf with the specified leaf index
sourcepub fn new_single(key: RpoDigest, value: Word) -> Self
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.
sourcepub fn new_multiple(
entries: Vec<(RpoDigest, Word)>,
) -> Result<Self, SmtLeafError>
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
sourcepub fn index(&self) -> LeafIndex<SMT_DEPTH>
pub fn index(&self) -> LeafIndex<SMT_DEPTH>
Returns the leaf’s index in the super::Smt
sourcepub fn num_entries(&self) -> u64
pub fn num_entries(&self) -> u64
Returns the number of entries stored in the leaf
sourcepub fn to_elements(&self) -> Vec<Felt>
pub fn to_elements(&self) -> Vec<Felt>
Converts a leaf to a list of field elements
sourcepub fn into_elements(self) -> Vec<Felt>
pub fn into_elements(self) -> Vec<Felt>
Converts a leaf to a list of field elements
sourcepub fn into_entries(self) -> Vec<(RpoDigest, Word)>
pub fn into_entries(self) -> Vec<(RpoDigest, Word)>
Converts a leaf the key-value pairs in the leaf
Trait Implementations§
source§impl Deserializable for SmtLeaf
impl Deserializable for SmtLeaf
source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
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 moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl Serializable for SmtLeaf
impl Serializable for SmtLeaf
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
Serializes
self
into bytes and writes these bytes into the target
.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Returns an estimate of how many bytes are needed to represent self. Read more
impl Eq for SmtLeaf
impl StructuralPartialEq for SmtLeaf
Auto Trait Implementations§
impl Freeze for SmtLeaf
impl RefUnwindSafe for SmtLeaf
impl Send for SmtLeaf
impl Sync for SmtLeaf
impl Unpin for SmtLeaf
impl UnwindSafe for SmtLeaf
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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)