Struct miden_objects::notes::NoteAssets
source · pub struct NoteAssets { /* private fields */ }Expand description
An asset container for a note.
A note must contain at least 1 asset and can contain up to 256 assets. No duplicates are allowed, but the order of assets is unspecified.
All the assets in a note can be reduced to a single commitment which is computed by sequentially hashing the assets. Note that the same list of assets can result in two different commitments if the asset ordering is different.
Implementations§
source§impl NoteAssets
impl NoteAssets
sourcepub const MAX_NUM_ASSETS: usize = 256usize
pub const MAX_NUM_ASSETS: usize = 256usize
The maximum number of assets which can be carried by a single note.
sourcepub fn new(assets: &[Asset]) -> Result<Self, NoteError>
pub fn new(assets: &[Asset]) -> Result<Self, NoteError>
Returns new NoteAssets constructed from the provided list of assets.
§Errors
Returns an error if:
- The asset list is empty.
- The list contains more than 256 assets.
- There are duplicate assets in the list.
sourcepub fn commitment(&self) -> Digest
pub fn commitment(&self) -> Digest
Returns a commitment to the note’s assets.
sourcepub fn num_assets(&self) -> usize
pub fn num_assets(&self) -> usize
Returns the number of assets.
sourcepub fn to_padded_assets(&self) -> Vec<Felt>
pub fn to_padded_assets(&self) -> Vec<Felt>
Returns all assets represented as a vector of field elements.
The vector is padded with ZEROs so that its length is a multiple of 8. This is useful because hashing the returned elements results in the note asset commitment.
Trait Implementations§
source§impl Clone for NoteAssets
impl Clone for NoteAssets
source§fn clone(&self) -> NoteAssets
fn clone(&self) -> NoteAssets
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for NoteAssets
impl Debug for NoteAssets
source§impl Deserializable for NoteAssets
impl Deserializable for NoteAssets
source§fn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R ) -> Result<Self, DeserializationError>
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 PartialEq for NoteAssets
impl PartialEq for NoteAssets
source§impl Serializable for NoteAssets
impl Serializable for NoteAssets
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self into bytes and writes these bytes into the target.