#[repr(C)]pub struct Asset {
pub id: AssetId,
pub value: Word,
}Expand description
A fungible or non-fungible asset encoded as an asset id and a value word.
The id identifies the asset in a vault (issuing faucet, asset class, composition rule);
value is the asset contents.
Fields§
§id: AssetIdThe asset’s id, which identifies it in a vault.
value: WordThe asset’s contents.
Implementations§
Source§impl Asset
impl Asset
Sourcepub fn new(id: impl Into<AssetId>, value: impl Into<Word>) -> Self
pub fn new(id: impl Into<AssetId>, value: impl Into<Word>) -> Self
Creates a new Asset from its id and value word.
Sourcepub fn amount(&self) -> AssetAmount
pub fn amount(&self) -> AssetAmount
Returns this asset’s fungible amount.
The composition rule is read from the asset id with AssetId::composition, which
executes the protocol library’s asset::id_into_composition procedure.
§Panics
Panics if the composition bits of the asset id hold an unrecognized value, if the asset is
not fungible, or if its amount exceeds AssetAmount::MAX_U64.
Sourcepub fn is_fungible(&self) -> bool
pub fn is_fungible(&self) -> bool
Returns true if this asset is fungible.
The composition rule is read from the asset id with AssetId::composition, which
executes the protocol library’s asset::id_into_composition procedure.
§Panics
Panics if the composition bits of the asset id hold an unrecognized value.
Trait Implementations§
impl Copy for Asset
impl Eq for Asset
Source§impl FromFeltRepr for Asset
impl FromFeltRepr for Asset
Source§const FIXED_LEN: Option<usize>
const FIXED_LEN: Option<usize>
Source§fn from_felt_repr(reader: &mut FeltReader<'_>) -> FeltReprResult<Self>
fn from_felt_repr(reader: &mut FeltReader<'_>) -> FeltReprResult<Self>
FeltReader, consuming the required elements.impl StructuralPartialEq for Asset
Source§impl ToFeltRepr for Asset
impl ToFeltRepr for Asset
Source§fn write_felt_repr(&self, writer: &mut FeltWriter<'_>)
fn write_felt_repr(&self, writer: &mut FeltWriter<'_>)
Source§fn to_felt_repr(&self) -> Vec<Felt>
fn to_felt_repr(&self) -> Vec<Felt>
Vec<Felt>.Auto Trait Implementations§
impl Freeze for Asset
impl RefUnwindSafe for Asset
impl Send for Asset
impl Sync for Asset
impl Unpin for Asset
impl UnsafeUnpin for Asset
impl UnwindSafe for Asset
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more