Struct cosmwasm_std::Int128
source · pub struct Int128(/* private fields */);
Expand description
An implementation of i128 that is using strings for JSON encoding/decoding, such that the full i128 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 i128
to get the value out:
let a = Int128::from(258i128);
assert_eq!(a.i128(), 258);
Implementations§
source§impl Int128
impl Int128
pub const MAX: Int128 = _
pub const MIN: Int128 = _
sourcepub const fn new(value: i128) -> Self
pub const fn new(value: i128) -> Self
Creates a Int128(value).
This method is less flexible than from
but can be called in a const context.
pub const fn from_be_bytes(data: [u8; 16]) -> Self
pub const fn from_le_bytes(data: [u8; 16]) -> Self
sourcepub const fn to_be_bytes(self) -> [u8; 16]
pub const fn to_be_bytes(self) -> [u8; 16]
Returns a copy of the number as big endian bytes.
sourcepub const fn to_le_bytes(self) -> [u8; 16]
pub const fn to_le_bytes(self) -> [u8; 16]
Returns a copy of the number as little endian bytes.
pub const fn is_zero(&self) -> bool
pub const fn is_negative(&self) -> bool
pub const fn pow(self, exp: u32) -> Self
sourcepub fn checked_multiply_ratio<A: Into<Self>, B: Into<Self>>(
&self,
numerator: A,
denominator: B
) -> Result<Self, CheckedMultiplyRatioError>
pub fn checked_multiply_ratio<A: Into<Self>, B: Into<Self>>( &self, numerator: A, denominator: B ) -> Result<Self, CheckedMultiplyRatioError>
Returns self * numerator / denominator
.
Due to the nature of the integer division involved, the result is always floored. E.g. 5 * 99/100 = 4.
pub fn checked_add(self, other: Self) -> Result<Self, OverflowError>
pub fn checked_sub(self, other: Self) -> Result<Self, OverflowError>
pub fn checked_mul(self, other: Self) -> Result<Self, OverflowError>
pub fn checked_pow(self, exp: u32) -> Result<Self, OverflowError>
pub fn checked_div(self, other: Self) -> Result<Self, DivisionError>
pub fn checked_div_euclid(self, other: Self) -> Result<Self, DivisionError>
pub fn checked_rem(self, other: Self) -> Result<Self, DivideByZeroError>
pub fn checked_shr(self, other: u32) -> Result<Self, OverflowError>
pub fn checked_shl(self, other: u32) -> Result<Self, OverflowError>
pub fn wrapping_add(self, other: Self) -> Self
pub fn wrapping_sub(self, other: Self) -> Self
pub fn wrapping_mul(self, other: Self) -> Self
pub fn wrapping_pow(self, other: u32) -> Self
pub fn saturating_add(self, other: Self) -> Self
pub fn saturating_sub(self, other: Self) -> Self
pub fn saturating_mul(self, other: Self) -> Self
pub fn saturating_pow(self, exp: u32) -> Self
pub const fn abs_diff(self, other: Self) -> Uint128
pub const fn abs(self) -> Self
pub const fn unsigned_abs(self) -> Uint128
sourcepub const fn strict_neg(self) -> Self
pub const fn strict_neg(self) -> Self
Strict negation. Computes -self, panicking if self == MIN.
This is the same as Int128::neg
but const.
Trait Implementations§
source§impl AddAssign<&Int128> for Int128
impl AddAssign<&Int128> for Int128
source§fn add_assign(&mut self, other: &Int128)
fn add_assign(&mut self, other: &Int128)
Performs the
+=
operation. Read moresource§impl AddAssign for Int128
impl AddAssign for Int128
source§fn add_assign(&mut self, rhs: Int128)
fn add_assign(&mut self, rhs: Int128)
Performs the
+=
operation. Read moresource§impl<'de> Deserialize<'de> for Int128
impl<'de> Deserialize<'de> for Int128
source§fn deserialize<D>(deserializer: D) -> Result<Int128, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Int128, D::Error>where
D: Deserializer<'de>,
Deserialized from an integer string using base 10
source§impl Div<Int128> for SignedDecimal
impl Div<Int128> for SignedDecimal
source§impl DivAssign<&Int128> for Int128
impl DivAssign<&Int128> for Int128
source§fn div_assign(&mut self, other: &Int128)
fn div_assign(&mut self, other: &Int128)
Performs the
/=
operation. Read moresource§impl DivAssign<Int128> for SignedDecimal
impl DivAssign<Int128> for SignedDecimal
source§fn div_assign(&mut self, rhs: Int128)
fn div_assign(&mut self, rhs: Int128)
Performs the
/=
operation. Read moresource§impl DivAssign for Int128
impl DivAssign for Int128
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/=
operation. Read moresource§impl Fraction<Int128> for SignedDecimal
impl Fraction<Int128> for SignedDecimal
source§impl JsonSchema for Int128
impl JsonSchema for Int128
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref
keyword. Read moresource§impl MulAssign<&Int128> for Int128
impl MulAssign<&Int128> for Int128
source§fn mul_assign(&mut self, other: &Int128)
fn mul_assign(&mut self, other: &Int128)
Performs the
*=
operation. Read moresource§impl MulAssign for Int128
impl MulAssign for Int128
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl Ord for Int128
impl Ord for Int128
source§impl PartialEq<&Int128> for Int128
impl PartialEq<&Int128> for Int128
source§impl<'a> PartialEq<Int128> for &'a Int128
impl<'a> PartialEq<Int128> for &'a Int128
source§impl PartialEq for Int128
impl PartialEq for Int128
source§impl PartialOrd for Int128
impl PartialOrd for Int128
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 RemAssign<&Int128> for Int128
impl RemAssign<&Int128> for Int128
source§fn rem_assign(&mut self, other: &Int128)
fn rem_assign(&mut self, other: &Int128)
Performs the
%=
operation. Read moresource§impl RemAssign for Int128
impl RemAssign for Int128
source§fn rem_assign(&mut self, rhs: Int128)
fn rem_assign(&mut self, rhs: Int128)
Performs the
%=
operation. Read moresource§impl ShlAssign<&u32> for Int128
impl ShlAssign<&u32> for Int128
source§fn shl_assign(&mut self, other: &u32)
fn shl_assign(&mut self, other: &u32)
Performs the
<<=
operation. Read moresource§impl ShlAssign<u32> for Int128
impl ShlAssign<u32> for Int128
source§fn shl_assign(&mut self, rhs: u32)
fn shl_assign(&mut self, rhs: u32)
Performs the
<<=
operation. Read moresource§impl ShrAssign<&u32> for Int128
impl ShrAssign<&u32> for Int128
source§fn shr_assign(&mut self, other: &u32)
fn shr_assign(&mut self, other: &u32)
Performs the
>>=
operation. Read moresource§impl ShrAssign<u32> for Int128
impl ShrAssign<u32> for Int128
source§fn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
Performs the
>>=
operation. Read moresource§impl SubAssign<&Int128> for Int128
impl SubAssign<&Int128> for Int128
source§fn sub_assign(&mut self, other: &Int128)
fn sub_assign(&mut self, other: &Int128)
Performs the
-=
operation. Read moresource§impl SubAssign for Int128
impl SubAssign for Int128
source§fn sub_assign(&mut self, rhs: Int128)
fn sub_assign(&mut self, rhs: Int128)
Performs the
-=
operation. Read moreimpl Copy for Int128
impl Eq for Int128
impl StructuralPartialEq for Int128
Auto Trait Implementations§
impl Freeze for Int128
impl RefUnwindSafe for Int128
impl Send for Int128
impl Sync for Int128
impl Unpin for Int128
impl UnwindSafe for Int128
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