Struct feeless::units::Rai[][src]

pub struct Rai(_);

Special bounded container for the smallest unit, rai.

Can not contain values outside of 0 to u128::MAX. To get around this, use UnboundedRai or one of the other denominations: Nano, Cents, MicroNano.

use feeless::Rai;

fn main() -> anyhow::Result<()> {
use feeless::units::Nano;
    let rai = Rai::new(1000000000000000000000000000000u128);
    assert_eq!(rai.to_nano(), Nano::new(1));
    Ok(())
}

Implementations

impl Rai[src]

pub fn new<T: Into<u128>>(v: T) -> Self[src]

Create a new Rai instance. The value must be Into. This might change to something more flexible soon!

pub fn from_hex(s: &str) -> Result<Self, FeelessError>[src]

pub fn zero() -> Self[src]

pub fn max() -> Self[src]

pub fn to_nano(&self) -> Nano[src]

pub fn to_cents(&self) -> Cents[src]

pub fn to_micro_nano(&self) -> MicroNano[src]

pub fn to_unbounded(&self) -> UnboundedRai[src]

pub fn to_vec(&self) -> Vec<u8>[src]

pub fn to_hex_string(&self) -> String[src]

pub fn to_u128(&self) -> u128[src]

pub fn to_big_decimal(&self) -> BigDecimal[src]

pub fn checked_add(&self, rhs: &Self) -> Option<Self>[src]

pub fn checked_sub(&self, rhs: &Self) -> Option<Self>[src]

Trait Implementations

impl Clone for Rai[src]

impl Debug for Rai[src]

impl<'de> Deserialize<'de> for Rai[src]

impl Display for Rai[src]

impl Eq for Rai[src]

impl From<&'_ Rai> for Nano[src]

impl From<&'_ Rai> for Cents[src]

impl From<&'_ Rai> for MicroNano[src]

impl From<&'_ Rai> for UnboundedRai[src]

impl From<Rai> for Nano[src]

impl From<Rai> for Cents[src]

impl From<Rai> for MicroNano[src]

impl From<Rai> for UnboundedRai[src]

impl From<u128> for Rai[src]

impl FromStr for Rai[src]

type Err = FeelessError

The associated error which can be returned from parsing.

impl PartialEq<Rai> for Rai[src]

impl PartialEq<u128> for Rai[src]

impl PartialOrd<Rai> for Rai[src]

impl PartialOrd<u128> for Rai[src]

impl Serialize for Rai[src]

This serializer and deserializer are for strings with decimal numbers. See serialize_to_hex and deserialize_from_hex if you expect your strings to be hex.

impl StructuralEq for Rai[src]

impl StructuralPartialEq for Rai[src]

impl TryFrom<&'_ [u8]> for Rai[src]

type Error = FeelessError

The type returned in the event of a conversion error.

impl TryFrom<&'_ BigDecimal> for Rai[src]

type Error = FeelessError

The type returned in the event of a conversion error.

fn try_from(value: &BigDecimal) -> Result<Self, Self::Error>[src]

Convert from BigDecimal into Rai, removing any fraction.

It’s up to the caller to round to a whole number beforehand.

One Rai is monetarily insignificant, but if you’re using fractions and trying to encode data this might bite you!

Auto Trait Implementations

impl RefUnwindSafe for Rai

impl Send for Rai

impl Sync for Rai

impl Unpin for Rai

impl UnwindSafe for Rai

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,