#[repr(C)]pub struct Asset {
pub key: Word,
pub value: Word,
}Expand description
A fungible or non-fungible asset encoded as separate vault key and value words.
The key identifies the asset in the account vault and the value stores the corresponding
asset contents. This matches the v0.14 protocol/base ABI.
Fields§
§key: WordThe asset’s vault key.
value: WordThe asset’s vault value.
Implementations§
Source§impl Asset
impl Asset
Sourcepub fn new(key: impl Into<Word>, value: impl Into<Word>) -> Self
pub fn new(key: impl Into<Word>, value: impl Into<Word>) -> Self
Creates a new Asset from its key and value words.
Sourcepub fn amount(&self) -> AssetAmount
pub fn amount(&self) -> AssetAmount
Returns this asset’s fungible amount.
Intended for kernel-encoded assets (e.g. the ones returned by the get_assets
bindings), whose encoding invariants make the composition bit sufficient to discriminate
fungibility.
§Panics
Panics if the asset is not fungible or 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.
Intended for kernel-encoded assets (e.g. the ones returned by the get_assets
bindings), whose encoding invariants make the composition bit sufficient to discriminate
fungibility.
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