pub struct Hbar(/* private fields */);
Expand description
A quantity of hbar
.
Implementations§
source§impl Hbar
impl Hbar
sourcepub const fn new(amount: i64) -> Self
pub const fn new(amount: i64) -> Self
Create a Hbar
containing amount ℏ
.
§Examples
let hbar = Hbar::new(52);
assert_eq!(hbar.to_string(), "52 ℏ");
sourcepub const fn from_tinybars(tinybars: Tinybar) -> Self
pub const fn from_tinybars(tinybars: Tinybar) -> Self
Convert from tinybars
to Hbar
.
§Examples
let hbar = Hbar::from_tinybars(250);
assert_eq!(hbar.to_string(), "250 tℏ");
sourcepub fn from_unit<T>(amount: T, unit: HbarUnit) -> Self
pub fn from_unit<T>(amount: T, unit: HbarUnit) -> Self
Convert from amount
in unit
to Hbar
.
Truncates amount
to the nearest tinybar if the resulting Hbar
is not an integer amount of tinybar.
§Panics
- if
amount * unit.tinybars()
would overflow a i64.
§Examples
use hedera::Hbar;
use hedera::HbarUnit;
let value = Hbar::from_unit(20, HbarUnit::Millibar);
assert_eq!(value.to_string(), "0.02 ℏ");
sourcepub const fn to_tinybars(self) -> Tinybar
pub const fn to_tinybars(self) -> Tinybar
Returns the value of self
in Tinybar
s.
Trait Implementations§
source§impl AddAssign for Hbar
impl AddAssign for Hbar
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl<T> DivAssign<T> for Hbar
impl<T> DivAssign<T> for Hbar
source§fn div_assign(&mut self, rhs: T)
fn div_assign(&mut self, rhs: T)
Performs the
/=
operation. Read moresource§impl<T> MulAssign<T> for Hbar
impl<T> MulAssign<T> for Hbar
source§fn mul_assign(&mut self, rhs: T)
fn mul_assign(&mut self, rhs: T)
Performs the
*=
operation. Read moresource§impl Ord for Hbar
impl Ord for Hbar
source§impl PartialEq for Hbar
impl PartialEq for Hbar
source§impl PartialOrd for Hbar
impl PartialOrd for Hbar
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign for Hbar
impl SubAssign for Hbar
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Copy for Hbar
impl Eq for Hbar
impl StructuralPartialEq for Hbar
Auto Trait Implementations§
impl Freeze for Hbar
impl RefUnwindSafe for Hbar
impl Send for Hbar
impl Sync for Hbar
impl Unpin for Hbar
impl UnwindSafe for Hbar
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
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request