Struct cosmwasm_std::Uint512
source · [−]pub struct Uint512(_);
Expand description
An implementation of u512 that is using strings for JSON encoding/decoding, such that the full u512 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 = Uint512::from(258u128);
let b = Uint512::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
sourceimpl Uint512
impl Uint512
pub const MAX: Uint512
sourcepub fn new(value: [u8; 64]) -> Self
pub fn new(value: [u8; 64]) -> Self
Creates a Uint512(value) from a big endian representation. It’s just an alias for
from_big_endian
.
pub const fn from_be_bytes(data: [u8; 64]) -> Self
pub const fn from_le_bytes(data: [u8; 64]) -> Self
sourcepub const fn from_uint256(num: Uint256) -> Self
pub const fn from_uint256(num: Uint256) -> Self
A conversion from Uint256
that, unlike the one provided by the From
trait,
can be used in a const
context.
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 fn is_zero(&self) -> bool
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_div(self, other: Self) -> Result<Self, DivideByZeroError>
pub fn checked_rem(self, other: Self) -> Result<Self, DivideByZeroError>
pub fn checked_shr(self, other: u32) -> Result<Self, OverflowError>
pub fn saturating_add(self, other: Self) -> Self
pub fn saturating_sub(self, other: Self) -> Self
pub fn saturating_mul(self, other: Self) -> Self
Trait Implementations
sourceimpl<'a> AddAssign<&'a Uint512> for Uint512
impl<'a> AddAssign<&'a Uint512> for Uint512
sourcefn add_assign(&mut self, rhs: &'a Uint512)
fn add_assign(&mut self, rhs: &'a Uint512)
Performs the +=
operation. Read more
sourceimpl AddAssign<Uint512> for Uint512
impl AddAssign<Uint512> for Uint512
sourcefn add_assign(&mut self, rhs: Uint512)
fn add_assign(&mut self, rhs: Uint512)
Performs the +=
operation. Read more
sourceimpl<'de> Deserialize<'de> for Uint512
impl<'de> Deserialize<'de> for Uint512
sourcefn deserialize<D>(deserializer: D) -> Result<Uint512, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Uint512, D::Error> where
D: Deserializer<'de>,
Deserialized from an integer string using base 10
sourceimpl<'a> DivAssign<&'a Uint512> for Uint512
impl<'a> DivAssign<&'a Uint512> for Uint512
sourcefn div_assign(&mut self, rhs: &'a Uint512)
fn div_assign(&mut self, rhs: &'a Uint512)
Performs the /=
operation. Read more
sourceimpl DivAssign<Uint512> for Uint512
impl DivAssign<Uint512> for Uint512
sourcefn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the /=
operation. Read more
sourceimpl JsonSchema for Uint512
impl JsonSchema for Uint512
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn 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 more
sourceimpl<'a> MulAssign<&'a Uint512> for Uint512
impl<'a> MulAssign<&'a Uint512> for Uint512
sourcefn mul_assign(&mut self, rhs: &'a Uint512)
fn mul_assign(&mut self, rhs: &'a Uint512)
Performs the *=
operation. Read more
sourceimpl MulAssign<Uint512> for Uint512
impl MulAssign<Uint512> for Uint512
sourcefn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the *=
operation. Read more
sourceimpl Ord for Uint512
impl Ord for Uint512
sourceimpl PartialOrd<Uint512> for Uint512
impl PartialOrd<Uint512> for Uint512
sourcefn partial_cmp(&self, other: &Uint512) -> Option<Ordering>
fn partial_cmp(&self, other: &Uint512) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
sourceimpl<'a> ShrAssign<&'a u32> for Uint512
impl<'a> ShrAssign<&'a u32> for Uint512
sourcefn shr_assign(&mut self, rhs: &'a u32)
fn shr_assign(&mut self, rhs: &'a u32)
Performs the >>=
operation. Read more
sourceimpl ShrAssign<u32> for Uint512
impl ShrAssign<u32> for Uint512
sourcefn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
Performs the >>=
operation. Read more
sourceimpl<'a> SubAssign<&'a Uint512> for Uint512
impl<'a> SubAssign<&'a Uint512> for Uint512
sourcefn sub_assign(&mut self, rhs: &'a Uint512)
fn sub_assign(&mut self, rhs: &'a Uint512)
Performs the -=
operation. Read more
sourceimpl SubAssign<Uint512> for Uint512
impl SubAssign<Uint512> for Uint512
sourcefn sub_assign(&mut self, rhs: Uint512)
fn sub_assign(&mut self, rhs: Uint512)
Performs the -=
operation. Read more
impl Copy for Uint512
impl Eq for Uint512
impl StructuralEq for Uint512
impl StructuralPartialEq for Uint512
Auto Trait Implementations
impl RefUnwindSafe for Uint512
impl Send for Uint512
impl Sync for Uint512
impl Unpin for Uint512
impl UnwindSafe for Uint512
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more