Struct miden_objects::assets::FungibleAsset
source · pub struct FungibleAsset { /* private fields */ }Expand description
A fungible asset.
A fungible asset consists of a faucet ID of the faucet which issued the asset as well as the asset amount. Asset amount is guaranteed to be 2^63 - 1 or smaller.
Implementations§
source§impl FungibleAsset
impl FungibleAsset
sourcepub const MAX_AMOUNT: u64 = 9_223_372_036_854_775_807u64
pub const MAX_AMOUNT: u64 = 9_223_372_036_854_775_807u64
Specifies a maximum amount value for fungible assets which can be at most a 63-bit value.
sourcepub fn new(faucet_id: AccountId, amount: u64) -> Result<Self, AssetError>
pub fn new(faucet_id: AccountId, amount: u64) -> Result<Self, AssetError>
Returns a fungible asset instantiated with the provided faucet ID and amount.
§Errors
Returns an error if:
- The faucet_id is not a valid fungible faucet ID.
- The provided amount is greater than 2^63 - 1.
sourcepub fn is_from_same_faucet(&self, other: &Self) -> bool
pub fn is_from_same_faucet(&self, other: &Self) -> bool
Returns true if this and the other assets were issued from the same faucet.
sourcepub fn vault_key(&self) -> Word
pub fn vault_key(&self) -> Word
Returns the key which is used to store this asset in the account vault.
sourcepub fn add(self, other: Self) -> Result<Self, AssetError>
pub fn add(self, other: Self) -> Result<Self, AssetError>
Adds two fungible assets together and returns the result.
§Errors
Returns an error if:
- The assets were not issued by the same faucet.
- The total value of assets is greater than or equal to 2^63.
Trait Implementations§
source§impl Clone for FungibleAsset
impl Clone for FungibleAsset
source§fn clone(&self) -> FungibleAsset
fn clone(&self) -> FungibleAsset
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for FungibleAsset
impl Debug for FungibleAsset
source§impl Display for FungibleAsset
impl Display for FungibleAsset
source§impl From<FungibleAsset> for Word
impl From<FungibleAsset> for Word
source§fn from(asset: FungibleAsset) -> Self
fn from(asset: FungibleAsset) -> Self
Converts to this type from the input type.
source§impl From<FungibleAsset> for [u8; 32]
impl From<FungibleAsset> for [u8; 32]
source§fn from(asset: FungibleAsset) -> Self
fn from(asset: FungibleAsset) -> Self
Converts to this type from the input type.
source§impl From<FungibleAsset> for Asset
impl From<FungibleAsset> for Asset
source§fn from(asset: FungibleAsset) -> Self
fn from(asset: FungibleAsset) -> Self
Converts to this type from the input type.
source§impl PartialEq for FungibleAsset
impl PartialEq for FungibleAsset
source§fn eq(&self, other: &FungibleAsset) -> bool
fn eq(&self, other: &FungibleAsset) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl TryFrom<[BaseElement; 4]> for FungibleAsset
impl TryFrom<[BaseElement; 4]> for FungibleAsset
impl Copy for FungibleAsset
impl Eq for FungibleAsset
impl StructuralPartialEq for FungibleAsset
Auto Trait Implementations§
impl Freeze for FungibleAsset
impl RefUnwindSafe for FungibleAsset
impl Send for FungibleAsset
impl Sync for FungibleAsset
impl Unpin for FungibleAsset
impl UnwindSafe for FungibleAsset
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