Struct jcm::Denomination
source · #[repr(C)]pub struct Denomination(/* private fields */);Expand description
Implementations§
source§impl Denomination
impl Denomination
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates a new Denomination.
sourcepub const fn integer(&self) -> u8
pub const fn integer(&self) -> u8
Gets the integer field of the Denomination.
sourcepub const fn exponent(&self) -> u8
pub const fn exponent(&self) -> u8
Gets the exponent field of the Denomination.
sourcepub fn value(&self) -> u64
pub fn value(&self) -> u64
Gets the value of the Denomination.
§Example
use jcm::Denomination;
let denom = Denomination::new();
assert_eq!(denom.integer(), 1);
assert_eq!(denom.exponent(), 0);
assert_eq!(denom.value(), 1);
let denom = Denomination::from_value(500);
assert_eq!(denom.integer(), 50);
assert_eq!(denom.exponent(), 1);
assert_eq!(denom.value(), 500);sourcepub fn from_value(val: u64) -> Self
pub fn from_value(val: u64) -> Self
Infallible function that converts a value into a Denomination.
§Example
use jcm::Denomination;
let denom = Denomination::from_value(2000);
assert_eq!(denom.integer(), 200);
assert_eq!(denom.exponent(), 1);
assert_eq!(denom.value(), 2000);sourcepub const fn len() -> usize
pub const fn len() -> usize
Gets the length of the Denomination.
sourcepub const fn is_empty(&self) -> bool
pub const fn is_empty(&self) -> bool
Gets whether the Denomination is empty.
sourcepub const fn is_valid(&self) -> bool
pub const fn is_valid(&self) -> bool
Gets whether the Denomination is valid.
sourcepub const fn to_u16(&self) -> u16
pub const fn to_u16(&self) -> u16
Converts the Denomination to a u16.
sourcepub const fn into_u16(self) -> u16
pub const fn into_u16(self) -> u16
Converts the Denomination to a u16.
sourcepub fn from_bytes(val: &[u8]) -> Self
pub fn from_bytes(val: &[u8]) -> Self
Infallible function to convert a byte buffer into a Denomination.
sourcepub fn valid_value(val: u64) -> bool
pub fn valid_value(val: u64) -> bool
Gets whether the value is a valid Denomination.
Trait Implementations§
source§impl Clone for Denomination
impl Clone for Denomination
source§fn clone(&self) -> Denomination
fn clone(&self) -> Denomination
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Denomination
impl Debug for Denomination
source§impl Default for Denomination
impl Default for Denomination
source§impl Display for Denomination
impl Display for Denomination
source§impl PartialEq for Denomination
impl PartialEq for Denomination
source§fn eq(&self, other: &Denomination) -> bool
fn eq(&self, other: &Denomination) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl TryFrom<&[u8]> for Denomination
impl TryFrom<&[u8]> for Denomination
source§impl TryFrom<u16> for Denomination
impl TryFrom<u16> for Denomination
source§impl TryFrom<u32> for Denomination
impl TryFrom<u32> for Denomination
source§impl TryFrom<u64> for Denomination
impl TryFrom<u64> for Denomination
source§impl TryFrom<u8> for Denomination
impl TryFrom<u8> for Denomination
impl Copy for Denomination
impl Eq for Denomination
impl StructuralPartialEq for Denomination
Auto Trait Implementations§
impl Freeze for Denomination
impl RefUnwindSafe for Denomination
impl Send for Denomination
impl Sync for Denomination
impl Unpin for Denomination
impl UnwindSafe for Denomination
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