pub enum Asset {
Native,
Credit(CreditAsset),
}Expand description
Represent an asset, either the native asset (XLM) or an asset issued.
Variants§
Native
The native asset (XLM).
Credit(CreditAsset)
A non-native asset, identified by asset code/issuer id.
Implementations§
Source§impl Asset
impl Asset
Sourcepub fn new_native() -> Asset
pub fn new_native() -> Asset
Create the native asset: Lumens.
Sourcepub fn new_credit<S>(code: S, issuer: PublicKey) -> Result<Asset>
pub fn new_credit<S>(code: S, issuer: PublicKey) -> Result<Asset>
Create the asset with code issued by issuer.
Sourcepub fn is_native(&self) -> bool
pub fn is_native(&self) -> bool
Returns true if the asset is a Native. Returns false otherwise.
Sourcepub fn as_credit(&self) -> Option<&CreditAsset>
pub fn as_credit(&self) -> Option<&CreditAsset>
If the asset is a Credit, returns its value. Returns None otherwise
Sourcepub fn as_credit_mut(&mut self) -> Option<&mut CreditAsset>
pub fn as_credit_mut(&mut self) -> Option<&mut CreditAsset>
If the asset is a Credit, returns its mutable value. Returns None otherwise
Trait Implementations§
Source§impl From<Asset> for TrustLineAsset
impl From<Asset> for TrustLineAsset
Source§impl ReadXdr for Asset
impl ReadXdr for Asset
Source§fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self>
fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self>
Read the XDR and construct the type. Read more
Source§fn read_xdr_to_end<R>(r: &mut Limited<R>) -> Result<Self, Error>where
R: Read,
fn read_xdr_to_end<R>(r: &mut Limited<R>) -> Result<Self, Error>where
R: Read,
Read the XDR and construct the type, and consider it an error if the
read does not completely consume the read implementation. Read more
Source§fn read_xdr_into<R>(&mut self, r: &mut Limited<R>) -> Result<(), Error>where
R: Read,
fn read_xdr_into<R>(&mut self, r: &mut Limited<R>) -> Result<(), Error>where
R: Read,
Read the XDR and construct the type. Read more
Source§fn read_xdr_into_to_end<R>(&mut self, r: &mut Limited<R>) -> Result<(), Error>where
R: Read,
fn read_xdr_into_to_end<R>(&mut self, r: &mut Limited<R>) -> Result<(), Error>where
R: Read,
Read the XDR into the existing value, and consider it an error if the
read does not completely consume the read implementation. Read more
Source§fn read_xdr_iter<R>(r: &mut Limited<R>) -> ReadXdrIter<&mut R, Self> ⓘwhere
R: Read,
fn read_xdr_iter<R>(r: &mut Limited<R>) -> ReadXdrIter<&mut R, Self> ⓘwhere
R: Read,
Create an iterator that reads the read implementation as a stream of
values that are read into the implementing type. Read more
impl Eq for Asset
impl StructuralPartialEq for Asset
Auto Trait Implementations§
impl Freeze for Asset
impl RefUnwindSafe for Asset
impl Send for Asset
impl Sync for Asset
impl Unpin 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
Mutably borrows from an owned value. Read more