pub struct Zatoshis(/* private fields */);
Expand description
A type-safe representation of some nonnegative amount of Zcash.
A Zatoshis can only be constructed from an integer that is within the valid monetary
range of {0..MAX_MONEY}
(where MAX_MONEY
= 21,000,000 × 10⁸ zatoshis).
Implementations§
Source§impl Zatoshis
impl Zatoshis
Sourcepub fn from_u64(amount: u64) -> Result<Self, BalanceError>
pub fn from_u64(amount: u64) -> Result<Self, BalanceError>
Creates a Zatoshis from a u64.
Returns an error if the amount is outside the range {0..MAX_MONEY}
.
Sourcepub const fn const_from_u64(amount: u64) -> Self
pub const fn const_from_u64(amount: u64) -> Self
Creates a constant Zatoshis from a u64.
Panics: if the amount is outside the range {0..MAX_MONEY}
.
Sourcepub fn from_nonnegative_i64(amount: i64) -> Result<Self, BalanceError>
pub fn from_nonnegative_i64(amount: i64) -> Result<Self, BalanceError>
Creates a Zatoshis from an i64.
Returns an error if the amount is outside the range {0..MAX_MONEY}
.
Sourcepub fn from_u64_le_bytes(bytes: [u8; 8]) -> Result<Self, BalanceError>
pub fn from_u64_le_bytes(bytes: [u8; 8]) -> Result<Self, BalanceError>
Reads an Zatoshis from an unsigned 64-bit little-endian integer.
Returns an error if the amount is outside the range {0..MAX_MONEY}
.
Sourcepub fn from_nonnegative_i64_le_bytes(
bytes: [u8; 8],
) -> Result<Self, BalanceError>
pub fn from_nonnegative_i64_le_bytes( bytes: [u8; 8], ) -> Result<Self, BalanceError>
Reads a Zatoshis from a signed integer represented as a two’s complement 64-bit little-endian value.
Returns an error if the amount is outside the range {0..MAX_MONEY}
.
Sourcepub fn to_i64_le_bytes(self) -> [u8; 8]
pub fn to_i64_le_bytes(self) -> [u8; 8]
Returns this Zatoshis encoded as a signed two’s complement 64-bit little-endian value.
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns whether or not this Zatoshis
is positive.
Sourcepub fn div_with_remainder(&self, divisor: NonZeroU64) -> QuotRem<Zatoshis>
pub fn div_with_remainder(&self, divisor: NonZeroU64) -> QuotRem<Zatoshis>
Divides this Zatoshis
value by the given divisor and returns the quotient and remainder.
Trait Implementations§
Source§impl From<&Zatoshis> for ZatBalance
impl From<&Zatoshis> for ZatBalance
Source§impl From<Zatoshis> for ZatBalance
impl From<Zatoshis> for ZatBalance
Source§impl Ord for Zatoshis
impl Ord for Zatoshis
Source§impl PartialOrd for Zatoshis
impl PartialOrd for Zatoshis
Source§impl TryFrom<ZatBalance> for Zatoshis
impl TryFrom<ZatBalance> for Zatoshis
Source§type Error = BalanceError
type Error = BalanceError
impl Copy for Zatoshis
impl Eq for Zatoshis
impl StructuralPartialEq for Zatoshis
Auto Trait Implementations§
impl Freeze for Zatoshis
impl RefUnwindSafe for Zatoshis
impl Send for Zatoshis
impl Sync for Zatoshis
impl Unpin for Zatoshis
impl UnwindSafe for Zatoshis
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more