pub struct Trx(/* private fields */);Expand description
An amount of TRX, stored internally as i64 sun.
Implementations§
Source§impl Trx
impl Trx
Sourcepub const fn from_sun_unchecked(sun: i64) -> Self
pub const fn from_sun_unchecked(sun: i64) -> Self
Construct directly from a sun value without validation.
Negative values are representable here because malformed on-chain data
must round-trip without panicking; prefer Trx::from_sun for
user-facing input.
Sourcepub fn from_sun(sun: i64) -> Result<Self, AmountError>
pub fn from_sun(sun: i64) -> Result<Self, AmountError>
Construct from a sun value, rejecting negatives.
Sourcepub fn from_trx(trx: f64) -> Result<Self, AmountError>
pub fn from_trx(trx: f64) -> Result<Self, AmountError>
Construct from a floating-point TRX value (e.g. 1.5 TRX).
Rejects negative and non-finite values, and values that overflow the
i64 sun range.
Sourcepub fn as_trx(self) -> f64
pub fn as_trx(self) -> f64
The value expressed as floating-point TRX (lossy for large amounts).
Sourcepub fn checked_add(self, rhs: Trx) -> Option<Trx>
pub fn checked_add(self, rhs: Trx) -> Option<Trx>
Checked addition, returning None on i64 overflow.
Sourcepub fn checked_sub(self, rhs: Trx) -> Option<Trx>
pub fn checked_sub(self, rhs: Trx) -> Option<Trx>
Checked subtraction, returning None on i64 overflow.
Trait Implementations§
impl Copy for Trx
Source§impl<'de> Deserialize<'de> for Trx
impl<'de> Deserialize<'de> for Trx
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Trx
Source§impl Ord for Trx
impl Ord for Trx
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Trx
impl PartialOrd for Trx
impl StructuralPartialEq for Trx
Auto Trait Implementations§
impl Freeze for Trx
impl RefUnwindSafe for Trx
impl Send for Trx
impl Sync for Trx
impl Unpin for Trx
impl UnsafeUnpin for Trx
impl UnwindSafe for Trx
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