Struct miden_objects::assets::NonFungibleAsset

source ·
pub struct NonFungibleAsset(/* private fields */);
Expand description

A commitment to a non-fungible asset.

The commitment is constructed as follows:

  • Hash the asset data producing [d0, d1, d2, d3].
  • Replace the value of d1 with the fauce id producing [d0, faucet_id, d2, d3].
  • Force the bit position ACCOUNT_ISFAUCET_MASK of d3 to be 0.

NonFungibleAsset itself does not contain the actual asset data. The container for this data NonFungibleAssetDetails struct.

Implementations§

source§

impl NonFungibleAsset

source

pub fn new(details: &NonFungibleAssetDetails) -> Result<Self, AssetError>

Returns a non-fungible asset created from the specified asset details.

§Errors

Returns an error if the provided faucet ID is not for a non-fungible asset faucet.

source

pub fn from_parts( faucet_id: AccountId, data_hash: Word ) -> Result<Self, AssetError>

Return a non-fungible asset created from the specified faucet and using the provided hash of the asset’s data.

Hash of the asset’s data is expected to be computed from the binary representation of the asset’s data.

§Errors

Returns an error if the provided faucet ID is not for a non-fungible asset faucet.

source

pub unsafe fn new_unchecked(value: Word) -> NonFungibleAsset

Creates a new NonFungibleAsset without checking its validity.

§Safety

This function required that the provided value is a valid word representation of a NonFungibleAsset.

source

pub fn vault_key(&self) -> Word

source

pub fn faucet_id(&self) -> AccountId

Return ID of the faucet which issued this asset.

Trait Implementations§

source§

impl Clone for NonFungibleAsset

source§

fn clone(&self) -> NonFungibleAsset

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 Debug for NonFungibleAsset

source§

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

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

impl Display for NonFungibleAsset

source§

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

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

impl From<NonFungibleAsset> for Word

source§

fn from(asset: NonFungibleAsset) -> Self

Converts to this type from the input type.
source§

impl From<NonFungibleAsset> for [u8; 32]

source§

fn from(asset: NonFungibleAsset) -> Self

Converts to this type from the input type.
source§

impl From<NonFungibleAsset> for Asset

source§

fn from(asset: NonFungibleAsset) -> Self

Converts to this type from the input type.
source§

impl PartialEq for NonFungibleAsset

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl TryFrom<[BaseElement; 4]> for NonFungibleAsset

§

type Error = AssetError

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

fn try_from(value: Word) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<[u8; 32]> for NonFungibleAsset

§

type Error = AssetError

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

fn try_from(value: [u8; 32]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for NonFungibleAsset

source§

impl Eq for NonFungibleAsset

source§

impl StructuralPartialEq for NonFungibleAsset

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more