pub struct Trx(/* private fields */);Expand description
An amount of TRX, stored internally as i64 sun.
User-facing constructors enforce non-negative amounts. Negative values remain representable only so malformed protobuf or serialized data can be inspected and round-tripped without panicking; arithmetic operations reject them.
Parses from and displays as a decimal TRX string with six fractional digits;
see parse_trx and format_trx.
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 from a sun value without rejecting negatives.
For protobuf round-tripping and malformed on-chain data only; prefer
Trx::from_sun for user input, balances, transfers, and contract calls.
Sourcepub const fn from_sun(sun: i64) -> Result<Self, AmountError>
pub const fn from_sun(sun: i64) -> Result<Self, AmountError>
Construct from a raw sun value, rejecting negatives.
Sourcepub fn checked_add(self, rhs: Trx) -> Option<Trx>
pub fn checked_add(self, rhs: Trx) -> Option<Trx>
Checked addition. Returns None on i64 overflow or if either operand
is negative.
Sourcepub fn checked_sub(self, rhs: Trx) -> Option<Trx>
pub fn checked_sub(self, rhs: Trx) -> Option<Trx>
Checked subtraction. Returns None on i64 overflow, if either operand
is negative, or if the result would be negative.
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>,
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,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes