Struct cosmwasm_std::Uint128[][src]

pub struct Uint128(pub u128);

A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.

Examples

Use from to create instances of this and u128 to get the value out:

let a = Uint128::from(123u128);
assert_eq!(a.u128(), 123);

let b = Uint128::from(42u64);
assert_eq!(b.u128(), 42);

let c = Uint128::from(70u32);
assert_eq!(c.u128(), 70);

Implementations

impl Uint128[src]

pub const fn new(value: u128) -> Self[src]

Creates a Uint128(value).

This method is less flexible than from but can be called in a const context.

pub const fn zero() -> Self[src]

Creates a Uint128(0)

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

Returns a copy of the internal data

pub fn is_zero(&self) -> bool[src]

pub fn checked_add(self, other: Self) -> Result<Self, OverflowError>[src]

pub fn checked_sub(self, other: Self) -> Result<Self, OverflowError>[src]

pub fn checked_mul(self, other: Self) -> Result<Self, OverflowError>[src]

pub fn checked_div(self, other: Self) -> Result<Self, DivideByZeroError>[src]

pub fn checked_div_euclid(self, other: Self) -> Result<Self, DivideByZeroError>[src]

pub fn checked_rem(self, other: Self) -> Result<Self, DivideByZeroError>[src]

pub fn wrapping_add(self, other: Self) -> Self[src]

pub fn wrapping_sub(self, other: Self) -> Self[src]

pub fn wrapping_mul(self, other: Self) -> Self[src]

pub fn wrapping_pow(self, other: u32) -> Self[src]

pub fn saturating_add(self, other: Self) -> Self[src]

pub fn saturating_sub(self, other: Self) -> Self[src]

pub fn saturating_mul(self, other: Self) -> Self[src]

pub fn saturating_pow(self, other: u32) -> Self[src]

impl Uint128[src]

pub fn multiply_ratio<A: Into<u128>, B: Into<u128>>(
    &self,
    numerator: A,
    denominator: B
) -> Uint128
[src]

Returns self * numerator / denominator

Trait Implementations

impl<'a> Add<&'a Uint128> for Uint128[src]

type Output = Self

The resulting type after applying the + operator.

impl Add<Uint128> for Uint128[src]

type Output = Self

The resulting type after applying the + operator.

impl<'a> AddAssign<&'a Uint128> for Uint128[src]

impl AddAssign<Uint128> for Uint128[src]

impl Clone for Uint128[src]

impl Copy for Uint128[src]

impl Debug for Uint128[src]

impl Default for Uint128[src]

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

fn deserialize<D>(deserializer: D) -> Result<Uint128, D::Error> where
    D: Deserializer<'de>, 
[src]

Deserialized from an integer string using base 10

impl Display for Uint128[src]

impl Eq for Uint128[src]

impl From<u128> for Uint128[src]

impl From<u16> for Uint128[src]

impl From<u32> for Uint128[src]

impl From<u64> for Uint128[src]

impl From<u8> for Uint128[src]

impl JsonSchema for Uint128[src]

impl Mul<Decimal> for Uint128[src]

Both du and ud with d: Decimal and u: Uint128 returns an Uint128. There is no specific reason for this decision other than the initial use cases we have. If you need a Decimal result for the same calculation, use Decimal(du) or Decimal(ud).

type Output = Self

The resulting type after applying the * operator.

impl Mul<Uint128> for Decimal[src]

type Output = Uint128

The resulting type after applying the * operator.

impl Ord for Uint128[src]

impl PartialEq<Uint128> for Uint128[src]

impl PartialOrd<Uint128> for Uint128[src]

impl Serialize for Uint128[src]

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
    S: Serializer
[src]

Serializes as an integer string using base 10

impl StructuralEq for Uint128[src]

impl StructuralPartialEq for Uint128[src]

impl<'a> Sum<&'a Uint128> for Uint128[src]

impl Sum<Uint128> for Uint128[src]

impl TryFrom<&'_ str> for Uint128[src]

type Error = StdError

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for Uint128

impl Send for Uint128

impl Sync for Uint128

impl Unpin for Uint128

impl UnwindSafe for Uint128

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

impl<T> FmtForward for T

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

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

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> Same<T> for T

type Output = T

Should always be Self

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, 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.