Struct cosmwasm_std::Int512
source · pub struct Int512(/* private fields */);
Expand description
An implementation of i512 that is using strings for JSON encoding/decoding, such that the full i512 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.
§Examples
Use from
to create instances out of primitive uint types or new
to provide big
endian bytes:
let a = Int512::from(258u128);
let b = Int512::new([
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8,
0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8, 2u8,
]);
assert_eq!(a, b);
Implementations§
source§impl Int512
impl Int512
pub const MAX: Int512 = _
pub const MIN: Int512 = _
sourcepub const fn new(value: [u8; 64]) -> Self
pub const fn new(value: [u8; 64]) -> Self
Creates a Int512(value) from a big endian representation. It’s just an alias for
from_be_bytes
.
pub const fn from_be_bytes(data: [u8; 64]) -> Self
pub const fn from_le_bytes(data: [u8; 64]) -> Self
sourcepub const fn to_be_bytes(self) -> [u8; 64]
pub const fn to_be_bytes(self) -> [u8; 64]
Returns a copy of the number as big endian bytes.
sourcepub const fn to_le_bytes(self) -> [u8; 64]
pub const fn to_le_bytes(self) -> [u8; 64]
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
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) -> Uint512
pub const fn abs(self) -> Self
pub const fn unsigned_abs(self) -> Uint512
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 Int512::neg
but const.
Trait Implementations§
source§impl AddAssign<&Int512> for Int512
impl AddAssign<&Int512> for Int512
source§fn add_assign(&mut self, other: &Int512)
fn add_assign(&mut self, other: &Int512)
Performs the
+=
operation. Read moresource§impl AddAssign for Int512
impl AddAssign for Int512
source§fn add_assign(&mut self, rhs: Int512)
fn add_assign(&mut self, rhs: Int512)
Performs the
+=
operation. Read moresource§impl<'de> Deserialize<'de> for Int512
impl<'de> Deserialize<'de> for Int512
source§fn deserialize<D>(deserializer: D) -> Result<Int512, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Int512, D::Error>where
D: Deserializer<'de>,
Deserialized from an integer string using base 10
source§impl DivAssign<&Int512> for Int512
impl DivAssign<&Int512> for Int512
source§fn div_assign(&mut self, other: &Int512)
fn div_assign(&mut self, other: &Int512)
Performs the
/=
operation. Read moresource§impl DivAssign for Int512
impl DivAssign for Int512
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/=
operation. Read moresource§impl JsonSchema for Int512
impl JsonSchema for Int512
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<&Int512> for Int512
impl MulAssign<&Int512> for Int512
source§fn mul_assign(&mut self, other: &Int512)
fn mul_assign(&mut self, other: &Int512)
Performs the
*=
operation. Read moresource§impl MulAssign for Int512
impl MulAssign for Int512
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl Ord for Int512
impl Ord for Int512
source§impl PartialOrd for Int512
impl PartialOrd for Int512
source§impl RemAssign<&Int512> for Int512
impl RemAssign<&Int512> for Int512
source§fn rem_assign(&mut self, other: &Int512)
fn rem_assign(&mut self, other: &Int512)
Performs the
%=
operation. Read moresource§impl RemAssign for Int512
impl RemAssign for Int512
source§fn rem_assign(&mut self, rhs: Int512)
fn rem_assign(&mut self, rhs: Int512)
Performs the
%=
operation. Read moresource§impl ShlAssign<&u32> for Int512
impl ShlAssign<&u32> for Int512
source§fn shl_assign(&mut self, other: &u32)
fn shl_assign(&mut self, other: &u32)
Performs the
<<=
operation. Read moresource§impl ShlAssign<u32> for Int512
impl ShlAssign<u32> for Int512
source§fn shl_assign(&mut self, rhs: u32)
fn shl_assign(&mut self, rhs: u32)
Performs the
<<=
operation. Read moresource§impl ShrAssign<&u32> for Int512
impl ShrAssign<&u32> for Int512
source§fn shr_assign(&mut self, other: &u32)
fn shr_assign(&mut self, other: &u32)
Performs the
>>=
operation. Read moresource§impl ShrAssign<u32> for Int512
impl ShrAssign<u32> for Int512
source§fn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
Performs the
>>=
operation. Read moresource§impl SubAssign<&Int512> for Int512
impl SubAssign<&Int512> for Int512
source§fn sub_assign(&mut self, other: &Int512)
fn sub_assign(&mut self, other: &Int512)
Performs the
-=
operation. Read moresource§impl SubAssign for Int512
impl SubAssign for Int512
source§fn sub_assign(&mut self, rhs: Int512)
fn sub_assign(&mut self, rhs: Int512)
Performs the
-=
operation. Read moreimpl Copy for Int512
impl Eq for Int512
impl StructuralPartialEq for Int512
Auto Trait Implementations§
impl Freeze for Int512
impl RefUnwindSafe for Int512
impl Send for Int512
impl Sync for Int512
impl Unpin for Int512
impl UnwindSafe for Int512
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more