pub struct U256(/* private fields */);Expand description
256-bit unsigned integer (wei amounts), little-endian 64-bit limbs.
Implementations§
Source§impl U256
impl U256
pub const ZERO: Self
pub const MAX: Self
pub fn from_u128(v: u128) -> Self
pub fn is_zero(&self) -> bool
pub fn from_be_slice(bytes: &[u8]) -> Option<Self>
pub fn to_be_bytes(self) -> [u8; 32]
pub fn from_hex(s: &str) -> Result<Self, ParseError>
pub fn from_dec(s: &str) -> Result<Self, ParseError>
pub fn checked_add(self, rhs: Self) -> Option<Self>
pub fn checked_sub(self, rhs: Self) -> Option<Self>
pub fn to_hex_quantity(self) -> String
Sourcepub fn format_ether(self) -> String
pub fn format_ether(self) -> String
Formats a wei amount in ether with up to 18 decimals, trailing zeros removed.
Trait Implementations§
impl Copy for U256
Source§impl<'de> Deserialize<'de> for U256
Accepts hex strings, decimal strings and JSON numbers, since clients differ.
impl<'de> Deserialize<'de> for U256
Accepts hex strings, decimal strings and JSON numbers, since clients differ.
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl Eq for U256
Source§impl FromStr for U256
impl FromStr for U256
Source§fn from_str(s: &str) -> Result<Self, ParseError>
fn from_str(s: &str) -> Result<Self, ParseError>
Accepts 0x hex quantities and plain decimals.
Source§type Err = ParseError
type Err = ParseError
The associated error which can be returned from parsing.
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
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