pub struct U256(/* private fields */);Expand description
An unsigned 256-bit integer. The limbs are most significant first, so the derived order is the numeric one.
Implementations§
Source§impl U256
impl U256
Source§impl U256
impl U256
Sourcepub fn from_quantity(text: &str) -> Result<U256, BadQuantity>
pub fn from_quantity(text: &str) -> Result<U256, BadQuantity>
0x and hex digits, as JSON-RPC writes a quantity. Leading zeros are
read (eth_call answers a whole word) and 0x alone is zero.
Sourcepub fn to_quantity(self) -> String
pub fn to_quantity(self) -> String
0x and the hex digits without leading zeros; zero is 0x0.
Sourcepub fn from_decimal(text: &str) -> Result<U256, BadQuantity>
pub fn from_decimal(text: &str) -> Result<U256, BadQuantity>
Decimal digits and nothing else.
Source§impl U256
impl U256
pub const ZERO: U256
pub const ONE: U256
pub const MAX: U256
pub const fn from_u64(value: u64) -> U256
pub const fn from_u128(value: u128) -> U256
pub fn from_be_bytes(bytes: [u8; 32]) -> U256
pub fn to_be_bytes(self) -> [u8; 32]
Sourcepub fn from_be_slice(bytes: &[u8]) -> Option<U256>
pub fn from_be_slice(bytes: &[u8]) -> Option<U256>
Up to 32 big-endian bytes, a shorter run read as if zero-padded on the left.
Sourcepub fn to_be_trimmed(self) -> Vec<u8> ⓘ
pub fn to_be_trimmed(self) -> Vec<u8> ⓘ
The value as big-endian bytes with no leading zeros; zero is empty.
pub const fn is_zero(self) -> bool
pub const fn to_u64(self) -> Option<u64>
pub const fn to_u128(self) -> Option<u128>
pub fn checked_add(self, other: U256) -> Option<U256>
pub fn checked_sub(self, other: U256) -> Option<U256>
pub fn checked_mul(self, other: U256) -> Option<U256>
pub fn saturating_add(self, other: U256) -> U256
pub fn saturating_mul(self, other: U256) -> U256
Trait Implementations§
impl Copy for U256
Source§impl<'de> Deserialize<'de> for U256
A quantity string. A bare JSON number is refused: it may have been a float.
impl<'de> Deserialize<'de> for U256
A quantity string. A bare JSON number is refused: it may have been a float.
Source§fn deserialize<D>(
deserializer: D,
) -> Result<U256, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<U256, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for U256
Source§impl Ord for U256
impl Ord for U256
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for U256
impl PartialOrd for U256
Source§impl Serialize for U256
impl Serialize for U256
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for U256
Auto Trait Implementations§
impl Freeze for U256
impl RefUnwindSafe for U256
impl Send for U256
impl Sync for U256
impl Unpin for U256
impl UnsafeUnpin for U256
impl UnwindSafe for U256
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.