Enum stellar_base::asset::Asset
source · 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 PartialEq for Asset
impl PartialEq for Asset
source§impl XDRDeserialize for Asset
impl XDRDeserialize for Asset
source§impl XDRSerialize for Asset
impl XDRSerialize for Asset
impl Eq for Asset
impl StructuralEq for Asset
impl StructuralPartialEq for Asset
Auto Trait Implementations§
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