pub struct Asset {
pub amount: i64,
pub symbol: Symbol,
}Expand description
The Asset struct represents a asset
Reference: https://github.com/AntelopeIO/cdt/blob/main/libraries/eosiolib/core/eosio/asset.hpp
§Examples
use antelope::{Asset, Symbol};
let quantity = Asset::from_amount(10000, Symbol::from("4,FOO"));
assert_eq!(10000, quantity.amount);Fields§
§amount: i64§symbol: SymbolImplementations§
Source§impl Asset
impl Asset
pub const MAX_AMOUNT: i64 = 4_611_686_018_427_387_903i64
pub fn new() -> Self
pub fn from_amount(amount: i64, symbol: Symbol) -> Self
Sourcepub fn is_amount_within_range(&self) -> bool
pub fn is_amount_within_range(&self) -> bool
Check if the amount doesn’t exceed the max amount
@return true - if the amount doesn’t exceed the max amount @return false - otherwise
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if the asset is valid. %A valid asset has its amount <= max_amount and its symbol name valid
@return true - if the asset is valid @return false - otherwise
Sourcepub fn set_amount(self, amount: i64)
pub fn set_amount(self, amount: i64)
Set the amount of the asset
@param a - New amount for the asset
Trait Implementations§
Source§impl AddAssign for Asset
impl AddAssign for Asset
Source§fn add_assign(&mut self, a: Self)
fn add_assign(&mut self, a: Self)
Addition Assignment operator
@param a - Another asset to add with this asset @post The amount of this asset is added with the amount of asset a
Source§impl Div for Asset
impl Div for Asset
Source§impl DivAssign<i64> for Asset
impl DivAssign<i64> for Asset
Source§fn div_assign(&mut self, a: i64)
fn div_assign(&mut self, a: i64)
Division assignment operator, with a number proceeding
@brief Division assignment operator, with a number proceeding @param self - The asset to be divided @param a - The divisor for the asset’s amount @return asset - Reference to the asset, which has been divided
Source§impl Mul<Asset> for i64
impl Mul<Asset> for i64
Source§impl Mul<i64> for Asset
impl Mul<i64> for Asset
Source§impl MulAssign<i64> for Asset
impl MulAssign<i64> for Asset
Source§fn mul_assign(&mut self, a: i64)
fn mul_assign(&mut self, a: i64)
Multiplication assignment operator, with a number
@details Multiplication assignment operator. Multiply the amount of this asset with a number and then assign the value to itself. @param a - The multiplier for the asset’s amount @return asset - Reference to this asset @post The amount of this asset is multiplied by a
Source§impl Ord for Asset
impl Ord for Asset
Source§impl PartialOrd for Asset
impl PartialOrd for Asset
Source§impl SubAssign for Asset
impl SubAssign for Asset
Source§fn sub_assign(&mut self, other: Asset)
fn sub_assign(&mut self, other: Asset)
Subtraction assignment operator
@param other - Another asset to subtract this asset with
@post The amount of this asset is subtracted by the amount of asset other