Skip to main content

U256

Struct U256 

Source
pub struct U256 { /* private fields */ }
Expand description

A 256-bit unsigned integer.

Limbs are least-significant-first in memory; the wire encoding is most-significant-first (see integration), matching xdrs’ u128.

Implementations§

Source§

impl U256

Source

pub const fn overflowing_add(self, rhs: U256) -> (U256, bool)

Wrapping addition, with a flag reporting whether it wrapped.

This is OpenZeppelin’s Math.add512, which returns the 512-bit sum as (high, low) because Solidity has no wider type and no bool-carrying tuple: its high is the carry, always zero or one. Here the carry is the flag, so (low, carry) carries the same information the other way round – widen it with U256::from(carry) if you need the high word as a value.

Source

pub const fn overflowing_sub(self, rhs: U256) -> (U256, bool)

Wrapping subtraction, with a flag reporting whether it wrapped.

Source

pub const fn checked_add(self, rhs: U256) -> Option<U256>

Addition, returning None on overflow.

Source

pub const fn checked_sub(self, rhs: U256) -> Option<U256>

Subtraction, returning None on overflow.

Source

pub const fn wrapping_add(self, rhs: U256) -> U256

Addition, wrapping on overflow.

Source

pub const fn wrapping_sub(self, rhs: U256) -> U256

Subtraction, wrapping on overflow.

Source

pub const fn saturating_add(self, rhs: U256) -> U256

Addition, saturating at U256::MAX.

Source

pub const fn saturating_sub(self, rhs: U256) -> U256

Subtraction, saturating at U256::ZERO.

Source

pub const fn overflowing_neg(self) -> (U256, bool)

Negation, with a flag reporting whether it wrapped.

Everything but zero wraps – there are no negative values here. The wrapped result is the two’s complement, which is what I256 is built on.

Source

pub const fn checked_neg(self) -> Option<U256>

Negation, returning None for every value but zero.

Source

pub const fn wrapping_neg(self) -> U256

Negation, wrapping: the two’s complement of self.

Source

pub const fn widening_mul_u128(a: u128, b: u128) -> U256

The exact 256-bit product of two 128-bit values.

The shape that dominates real call sites (a * b / c over token amounts). Cannot overflow, so no check and no Option; sixteen mul/mulhu pairs.

Source

pub const fn widening_mul(self, rhs: U256) -> (U256, U256)

The exact 512-bit product of two U256s, as (low, high).

Halves are ordered low-first, matching u128::widening_mul. OpenZeppelin’s Math.mul512 returns them the other way round.

Cannot overflow, so no check and no Option; sixty-four mul/mulhu pairs. This is the intermediate the full-precision mul_div family divides back down – reach for that rather than for the halves, unless the 512-bit value is the answer.

Source

pub const fn overflowing_mul_u32(self, rhs: u32) -> (U256, bool)

Multiplication by a 32-bit value, with a flag reporting overflow.

Separate from the general 256x256 multiply so scaling by a small constant does not drag the schoolbook loop in.

Source

pub const fn overflowing_mul(self, rhs: U256) -> (U256, bool)

Wrapping multiplication, with a flag reporting whether it wrapped.

Outlined on rv32; see U256::widening_mul_u128 and the note at the top of this module.

Source

pub const fn checked_mul(self, rhs: U256) -> Option<U256>

Multiplication, returning None on overflow.

Source

pub const fn wrapping_mul(self, rhs: U256) -> U256

Multiplication, wrapping on overflow.

Source

pub const fn saturating_mul(self, rhs: U256) -> U256

Multiplication, saturating at U256::MAX.

Source

pub const fn const_bitand(self, rhs: U256) -> U256

Bitwise AND, usable from a const fn.

Source

pub const fn const_bitor(self, rhs: U256) -> U256

Bitwise OR, usable from a const fn.

Source

pub const fn const_bitxor(self, rhs: U256) -> U256

Bitwise XOR, usable from a const fn.

Source

pub const fn const_not(self) -> U256

Bitwise NOT, usable from a const fn.

Source

pub const fn overflowing_shl(self, n: u32) -> (U256, bool)

Left shift, masking the shift amount to 0..256 and reporting whether the mask changed it. Mirrors u128::overflowing_shl.

Source

pub const fn wrapping_shl(self, n: u32) -> U256

Left shift, masking the shift amount to 0..256.

Source

pub const fn checked_shl(self, n: u32) -> Option<U256>

Left shift, returning None if the shift amount is at least 256.

Source

pub const fn overflowing_shr(self, n: u32) -> (U256, bool)

Right shift, masking the shift amount to 0..256 and reporting whether the mask changed it. Mirrors u128::overflowing_shr.

Source

pub const fn wrapping_shr(self, n: u32) -> U256

Right shift, masking the shift amount to 0..256.

Source

pub const fn checked_shr(self, n: u32) -> Option<U256>

Right shift, returning None if the shift amount is at least 256.

Source§

impl U256

Source

pub const fn div_rem_small(self, rhs: u32) -> (U256, u32)

Divides by a 32-bit value, returning the quotient and remainder.

§Panics

If rhs is zero.

Source

pub const fn div_rem(self, rhs: U256) -> (U256, U256)

Divides by another U256, returning the quotient and remainder.

§Panics

If rhs is zero, matching the primitive integers (which panic on a zero divisor regardless of overflow-checks).

Source

pub const fn checked_div_rem(self, rhs: U256) -> Option<(U256, U256)>

Divides by another U256, returning None if rhs is zero.

Source

pub const fn checked_div(self, rhs: U256) -> Option<U256>

Division, returning None if rhs is zero.

Source

pub const fn checked_rem(self, rhs: U256) -> Option<U256>

Remainder, returning None if rhs is zero.

Source§

impl U256

Source

pub const fn min(self, other: U256) -> U256

The smaller of two values. Math.min.

Shadows Ord::min in method position, which resolves to the same answer; this one is a const fn.

Source

pub const fn max(self, other: U256) -> U256

The larger of two values. Math.max.

Shadows Ord::max in method position, which resolves to the same answer; this one is a const fn.

Source

pub const fn clamp(self, min: U256, max: U256) -> U256

Clamps to the inclusive range min..=max.

§Panics

If min > max, matching Ord::clamp.

Source

pub const fn average(self, other: U256) -> U256

The average of two values, rounded toward zero, without an intermediate that overflows. Math.average.

(a + b) / 2 would wrap; (a & b) + (a ^ b) / 2 is the same value and never leaves the range.

Source

pub const fn checked_ceil_div(self, rhs: U256) -> Option<U256>

Division rounding toward positive infinity, returning None if rhs is zero. Math.ceilDiv.

Source

pub const fn ceil_div(self, rhs: U256) -> U256

Division rounding toward positive infinity. Math.ceilDiv.

§Panics

If rhs is zero, matching /.

Source

pub const fn checked_div_rounding( self, rhs: U256, rounding: Rounding, ) -> Option<U256>

Division following rounding, returning None if rhs is zero.

Source

pub const fn div_rounding(self, rhs: U256, rounding: Rounding) -> U256

Division following rounding.

§Panics

If rhs is zero, matching /.

Source

pub const fn checked_mul_div(x: U256, y: U256, d: U256) -> Option<U256>

floor(x * y / d) computed on the exact 512-bit product, returning None if d is zero or the quotient exceeds U256::MAX.

Math.mulDiv. The intermediate never has to fit in 256 bits, which is the whole point: x * y may be far past U256::MAX as long as the quotient is not.

Source

pub const fn mul_div(x: U256, y: U256, d: U256) -> U256

floor(x * y / d) computed on the exact 512-bit product. Math.mulDiv.

§Panics

If d is zero, or if the quotient does not fit in a U256. Both panics are unconditional rather than overflow-checks-gated, for the reason mul_div_u128 gives: this is an explicit exact-arithmetic call, not an operator with primitive behaviour to match.

Source

pub const fn checked_mul_div_rounding( x: U256, y: U256, d: U256, rounding: Rounding, ) -> Option<U256>

x * y / d computed on the exact 512-bit product, following rounding. Returns None if d is zero or the result exceeds U256::MAX. Math.mulDiv with a rounding argument.

Source

pub const fn mul_div_rounding( x: U256, y: U256, d: U256, rounding: Rounding, ) -> U256

x * y / d computed on the exact 512-bit product, following rounding.

§Panics

As mul_div.

Source

pub const fn checked_mul_shr(x: U256, y: U256, n: u32) -> Option<U256>

floor(x * y >> n) computed on the exact 512-bit product, returning None if the result exceeds U256::MAX or n is at least 256.

Math.mulShr, whose n is a uint8 and so cannot reach 256 at all.

Source

pub const fn mul_shr(x: U256, y: U256, n: u32) -> U256

floor(x * y >> n) computed on the exact 512-bit product. Math.mulShr.

§Panics

If n is at least 256, or if the result does not fit in a U256.

Source

pub const fn checked_mul_shr_rounding( x: U256, y: U256, n: u32, rounding: Rounding, ) -> Option<U256>

x * y >> n computed on the exact 512-bit product, following rounding. Math.mulShr with a rounding argument.

Source

pub const fn mul_shr_rounding( x: U256, y: U256, n: u32, rounding: Rounding, ) -> U256

x * y >> n computed on the exact 512-bit product, following rounding.

§Panics

As mul_shr.

Source

pub const fn checked_add_mod(x: U256, y: U256, m: U256) -> Option<U256>

(x + y) % m, computed on the exact 257-bit sum. Returns None if m is zero.

The EVM’s addmod, which Math.sol uses but does not re-export.

Source

pub const fn add_mod(x: U256, y: U256, m: U256) -> U256

(x + y) % m, computed on the exact 257-bit sum.

§Panics

If m is zero.

Source

pub const fn checked_mul_mod(x: U256, y: U256, m: U256) -> Option<U256>

(x * y) % m, computed on the exact 512-bit product. Returns None if m is zero.

The EVM’s mulmod, which Math.sol uses but does not re-export.

Source

pub const fn mul_mod(x: U256, y: U256, m: U256) -> U256

(x * y) % m, computed on the exact 512-bit product.

§Panics

If m is zero.

Source

pub const fn checked_mod_exp(b: U256, e: U256, m: U256) -> Option<U256>

b.pow(e) % m, returning None if m is zero. Math.tryModExp.

The zero-modulus refusal follows OpenZeppelin rather than the precompile it calls: EIP-198 treats a zero modulus as defined and answers zero, and tryModExp guards it in Solidity before the staticcall. A port is written against the library, so this matches the library.

Square-and-multiply over checked_mul_mod: one full-precision multiply-divide per bit of e, plus one more per set bit – up to 512 for a full-width exponent. See mod_exp for what that costs and why an attacker-chosen exponent is a gas-exhaustion surface.

Source

pub const fn mod_exp(b: U256, e: U256, m: U256) -> U256

b.pow(e) % m. Math.modExp.

§Cost

This is the most expensive function in the crate, by a wide margin, and the one place where being a library rather than a precompile really costs.

Math.modExp in Solidity is not an implementation: it is a staticcall to the EIP-198 precompile at address 0x05, so the bignum runs as native client code at a flat fee. Thruput’s syscall table – the actual analogue of the EVM’s precompile slots – carries kSHA256 and kVerifySignature (EVM 0x02 and 0x01) but nothing for modular exponentiation, so this runs inside the contract.

That means the loop is real work: once per bit of e, with one full-precision multiply-divide per bit and another per set bit, up to 512 of them for a full-width exponent. At the 4,712 gas the bench measures for one mul_div, a 256-bit exponent is on the order of two million. An entrypoint that lets a caller choose e or m is therefore a gas-exhaustion surface: bound the exponent, or charge for it.

If modular exponentiation ever becomes load-bearing here – RSA verification, anything with a pairing behind it – the answer is a host syscall alongside kSHA256, not a better loop. That is a protocol change rather than an SDK one, and it is tracked as https://github.com/thruputchain/thruput-sdk-rs/issues/383.

Two things this does have over the Solidity version. It is a const fn, where Math.modExp must be view because a staticcall is not pure. And it cannot silently answer zero: OpenZeppelin’s own documentation warns that on a chain without the precompile the staticcall succeeds and the result “may be incorrectly interpreted as 0”, which is not a failure mode an in-contract loop has.

§Panics

If m is zero.

Source

pub const fn inv_mod(a: U256, n: U256) -> U256

The modular multiplicative inverse of a in Z/nZ, or zero when a has no inverse (including when n is zero or one). Math.invMod.

Iterative extended Euclid. The Bézout coefficient is carried as a magnitude with an implied alternating sign, rather than as a signed value: consecutive coefficients always have opposite signs, so the recurrence on magnitudes is t[k+1] = t[k-1] + q * t[k], and the standard bound t <= n / gcd keeps every intermediate inside a U256.

Source

pub const fn inv_mod_prime(a: U256, p: U256) -> U256

The modular multiplicative inverse of a in Z/pZ for a prime p greater than two. Math.invModPrime.

Fermat’s little theorem: a^(p-2) = a^-1 (mod p). p is not checked for primality; a composite modulus produces a wrong answer rather than an error, exactly as in Solidity. Use inv_mod when the modulus is not known to be prime.

§Cost

This is mod_exp with a full-width exponent, so it is as expensive as that function’s worst case. It reads like a cheap helper and is not one.

§Panics

If p is zero. Note that this differs from inv_mod, which is total and answers zero for a degenerate modulus: swapping one for the other after establishing primality elsewhere turns that zero into an abort.

Source

pub const fn overflowing_pow(self, exp: u32) -> (U256, bool)

Exponentiation, with a flag reporting whether it wrapped.

0.pow(0) is one, matching the primitives.

Source

pub const fn checked_pow(self, exp: u32) -> Option<U256>

Exponentiation, returning None on overflow.

Source

pub const fn wrapping_pow(self, exp: u32) -> U256

Exponentiation, wrapping on overflow.

Source

pub const fn saturating_pow(self, exp: u32) -> U256

Exponentiation, saturating at U256::MAX.

Source

pub const fn pow(self, exp: u32) -> U256

Exponentiation.

§Panics

On overflow, if overflow-checks is on – otherwise it wraps, like the operators and like the primitives’ pow.

Source

pub const fn sqrt_rounding(self, rounding: Rounding) -> U256

The integer square root, following rounding. Math.sqrt with a rounding argument.

Source

pub const fn log2(self) -> u32

floor(log2(self)), or zero for zero. Math.log2.

Source

pub const fn log2_rounding(self, rounding: Rounding) -> u32

log2(self) following rounding, or zero for zero. Math.log2 with a rounding argument.

Source

pub const fn log10(self) -> u32

floor(log10(self)), or zero for zero. Math.log10.

Peels eight digits at a time with div_rem_small – 10^8 is the largest power of ten that is both a u32 and a whole number of digits – so this never links Knuth D, unlike the ladder of 256-bit constants Solidity uses.

Source

pub const fn log10_rounding(self, rounding: Rounding) -> u32

log10(self) following rounding, or zero for zero. Math.log10 with a rounding argument.

Source

pub const fn log256(self) -> u32

floor(log256(self)), or zero for zero. Math.log256.

One more than this is the number of bytes needed to write self.

Source

pub const fn log256_rounding(self, rounding: Rounding) -> u32

log256(self) following rounding, or zero for zero. Math.log256 with a rounding argument.

Source§

impl U256

Source

pub const fn cast_signed(self) -> I256

Reinterprets the bits as an I256.

No arithmetic: U256::MAX.cast_signed() is -1. Named after u128::cast_signed, which does the same thing at a narrower width.

Source§

impl U256

Source

pub const fn integer_sqrt(self) -> U256

The largest r such that r * r <= self.

Digit-by-digit (binary restoring): shifts, comparisons and subtractions, no division. Newton’s method costs a full 256-bit divide per iteration that LLVM inlines into the loop – uint’s Newton-based version measured 12,732 bytes of rv32 text, for a square root.

Source§

impl U256

Source

pub const ZERO: U256

The additive identity.

Source

pub const ONE: U256

The multiplicative identity.

Source

pub const MAX: U256

The largest representable value.

Source

pub const BITS: u32 = 256

The size of this integer in bits.

Source

pub const fn from_limbs(limbs: [u32; 8]) -> U256

Constructs a value from limbs, least-significant-first.

Source

pub const fn from(n: u128) -> U256

Constructs a value from a u128.

Inherent, and deliberately so. From is implemented for every unsigned width, which leaves U256::from(1000) ambiguous – an unsuffixed literal matches all of them – and an inherent function shadows the trait for the path form, pinning the literal to u128. It is also usable in const position, which From::from is not.

The trait impls are untouched, so .into() and generic T: Into<U256> code still convert from any width. What this shadowing costs is U256::from(x) for an x narrower than u128; use x.into() or from_u32 / from_u64 there.

Source

pub const fn from_u128(n: u128) -> U256

Constructs a value from a u128, under a name no trait shadows.

from is this function behind the literal-pinning shadow, and the From<u128> impl calls it too, so neither body depends on the shadowing to terminate.

Source

pub const fn from_u32(n: u32) -> U256

Constructs a value from a u32, without widening at the call site.

Source

pub const fn from_u64(n: u64) -> U256

Constructs a value from a u64, without widening at the call site.

Source

pub const fn to_limbs(self) -> [u32; 8]

Returns the limbs, least-significant-first.

Source

pub const fn is_zero(self) -> bool

Returns true if this is zero.

Source

pub const fn bit_len(self) -> u32

The number of significant bits: 0 for zero, otherwise one more than the index of the highest set bit.

Source

pub const fn leading_zeros(self) -> u32

The number of leading zero bits.

Source

pub const fn bit(self, i: u32) -> bool

Returns the bit at i, counting from the least significant.

Bits at or above BITS are zero, rather than a panic: callers index by a computed position (an exponent bit, a mask width), and the out-of-range answer is unambiguous.

Source

pub const fn const_cmp(self, other: U256) -> Ordering

Comparison usable from a const fn.

The Ord impl is the one callers want; it just is not const, and the arithmetic in this crate is. Same ordering, same answer.

Source

pub const fn to_be_bytes(self) -> [u8; 32]

Returns the big-endian byte representation.

Outlined on rv32 – every contract that stores a U256 pays for this one. See the inlining note in arith.

Source

pub const fn from_be_bytes(bytes: [u8; 32]) -> U256

Constructs a value from its big-endian byte representation.

Outlined on rv32; see the inlining note in arith.

Trait Implementations§

Source§

impl Add for U256

Source§

type Output = U256

The resulting type after applying the + operator.
Source§

fn add(self, rhs: U256) -> U256

Performs the + operation. Read more
Source§

impl AddAssign for U256

Source§

fn add_assign(&mut self, rhs: U256)

Performs the += operation. Read more
Source§

impl BitAnd for U256

Source§

type Output = U256

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: U256) -> U256

Performs the & operation. Read more
Source§

impl BitAndAssign for U256

Source§

fn bitand_assign(&mut self, rhs: U256)

Performs the &= operation. Read more
Source§

impl BitOr for U256

Source§

type Output = U256

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: U256) -> U256

Performs the | operation. Read more
Source§

impl BitOrAssign for U256

Source§

fn bitor_assign(&mut self, rhs: U256)

Performs the |= operation. Read more
Source§

impl BitXor for U256

Source§

type Output = U256

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: U256) -> U256

Performs the ^ operation. Read more
Source§

impl BitXorAssign for U256

Source§

fn bitxor_assign(&mut self, rhs: U256)

Performs the ^= operation. Read more
Source§

impl Clone for U256

Source§

fn clone(&self) -> U256

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CollectAuthHandles for U256

Source§

impl ContractTypeRefSpec for U256

Source§

const INFO: ContractTypeInfo<'static>

The type reference. Transitive type definitions are not carried here; they are retained via the linker-anchor mechanism (__THRUPUT_SPEC_ANCHOR_ROOT) and resolved by spec-tool.
Source§

const SIGNED_PREIMAGE: Option<&'static ContractTypeView<'static>> = _

How this type appears as a signed-token preimage (ContractTypeView::SignedToken’s payload): the type itself by default, or None for a type-erased payload (the SDK’s Opaque overrides this).
Source§

impl Copy for U256

Source§

impl Debug for U256

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Renders as 0x-prefixed hex.

Unlike the LowerHex/UpperHex impls this does not honour width or fill flags – Debug is for diagnostics, and a padded {:?} on an integer is not a thing callers ask for. Use {:x} when the exact textual shape matters.

Source§

impl Default for U256

Source§

fn default() -> U256

Returns the “default value” for a type. Read more
Source§

impl Display for U256

Available on crate feature fmt only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Div for U256

Source§

fn div(self, rhs: U256) -> U256

Division. Panics on a zero divisor regardless of overflow-checks, matching the primitive integers.

Source§

type Output = U256

The resulting type after applying the / operator.
Source§

impl DivAssign for U256

Source§

fn div_assign(&mut self, rhs: U256)

Performs the /= operation. Read more
Source§

impl Eq for U256

Source§

impl From<bool> for U256

Source§

fn from(b: bool) -> U256

Converts to this type from the input type.
Source§

impl From<u8> for U256

Source§

fn from(n: u8) -> U256

Converts to this type from the input type.
Source§

impl From<u16> for U256

Source§

fn from(n: u16) -> U256

Converts to this type from the input type.
Source§

impl From<u32> for U256

Source§

fn from(n: u32) -> U256

Converts to this type from the input type.
Source§

impl From<u64> for U256

Source§

fn from(n: u64) -> U256

Converts to this type from the input type.
Source§

impl From<u128> for U256

Source§

fn from(n: u128) -> U256

Converts to this type from the input type.
Source§

impl FromStr for U256

Available on crate feature fmt only.
Source§

type Err = ParseU256Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<U256, <U256 as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for U256

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoTopic for U256

Source§

fn into_topic(&self) -> TopicSrc<'_>

Source§

impl LowerHex for U256

Available on crate feature fmt only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Mintable for U256

Source§

fn mint_into_parent(preimage: U256, _children: &mut ChildNodeBuf) -> Self

Source§

impl MintableType for U256

Source§

impl Mul for U256

Source§

type Output = U256

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: U256) -> U256

Performs the * operation. Read more
Source§

impl Mul<u32> for U256

Source§

type Output = U256

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u32) -> U256

Performs the * operation. Read more
Source§

impl MulAssign for U256

Source§

fn mul_assign(&mut self, rhs: U256)

Performs the *= operation. Read more
Source§

impl MulAssign<u32> for U256

Source§

fn mul_assign(&mut self, rhs: u32)

Performs the *= operation. Read more
Source§

impl Not for U256

Source§

type Output = U256

The resulting type after applying the ! operator.
Source§

fn not(self) -> U256

Performs the unary ! operation using logical or bitwise negation. Read more
Source§

impl Ord for U256

Source§

fn cmp(&self, other: &U256) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for U256

Source§

fn eq(&self, other: &U256) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for U256

Source§

fn partial_cmp(&self, other: &U256) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'r> ReadXDR<'r> for U256

Source§

fn read_xdr<R>(r: &mut R) -> Result<U256, ReadError>
where R: Reader<'r>,

Reads an XDR value from the reader. Read more
Source§

fn read_xdr_in_place<'s, R>( r: &mut R, slot: Slot<'s, Self>, ) -> Result<Init<'s, Self>, ReadError>
where R: Reader<'r>,

Reads an XDR value directly into slot, without first building it on the stack. Read more
Source§

impl ReceiveAuthHandles for U256

Source§

fn receive_auth_handles( &mut self, _handles: &mut impl Iterator<Item = u32>, ) -> Result<(), AuthTokenError>

Source§

impl Rem for U256

Source§

fn rem(self, rhs: U256) -> U256

Remainder. Panics on a zero divisor regardless of overflow-checks, matching the primitive integers.

Source§

type Output = U256

The resulting type after applying the % operator.
Source§

impl RemAssign for U256

Source§

fn rem_assign(&mut self, rhs: U256)

Performs the %= operation. Read more
Source§

impl Shl<i8> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i8) -> U256

Performs the << operation. Read more
Source§

impl Shl<i16> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i16) -> U256

Performs the << operation. Read more
Source§

impl Shl<i32> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i32) -> U256

Performs the << operation. Read more
Source§

impl Shl<i64> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i64) -> U256

Performs the << operation. Read more
Source§

impl Shl<i128> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: i128) -> U256

Performs the << operation. Read more
Source§

impl Shl<isize> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: isize) -> U256

Performs the << operation. Read more
Source§

impl Shl<u8> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u8) -> U256

Performs the << operation. Read more
Source§

impl Shl<u16> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u16) -> U256

Performs the << operation. Read more
Source§

impl Shl<u32> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u32) -> U256

Performs the << operation. Read more
Source§

impl Shl<u64> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u64) -> U256

Performs the << operation. Read more
Source§

impl Shl<u128> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u128) -> U256

Performs the << operation. Read more
Source§

impl Shl<usize> for U256

Source§

type Output = U256

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: usize) -> U256

Performs the << operation. Read more
Source§

impl ShlAssign<i8> for U256

Source§

fn shl_assign(&mut self, rhs: i8)

Performs the <<= operation. Read more
Source§

impl ShlAssign<i16> for U256

Source§

fn shl_assign(&mut self, rhs: i16)

Performs the <<= operation. Read more
Source§

impl ShlAssign<i32> for U256

Source§

fn shl_assign(&mut self, rhs: i32)

Performs the <<= operation. Read more
Source§

impl ShlAssign<i64> for U256

Source§

fn shl_assign(&mut self, rhs: i64)

Performs the <<= operation. Read more
Source§

impl ShlAssign<i128> for U256

Source§

fn shl_assign(&mut self, rhs: i128)

Performs the <<= operation. Read more
Source§

impl ShlAssign<isize> for U256

Source§

fn shl_assign(&mut self, rhs: isize)

Performs the <<= operation. Read more
Source§

impl ShlAssign<u8> for U256

Source§

fn shl_assign(&mut self, rhs: u8)

Performs the <<= operation. Read more
Source§

impl ShlAssign<u16> for U256

Source§

fn shl_assign(&mut self, rhs: u16)

Performs the <<= operation. Read more
Source§

impl ShlAssign<u32> for U256

Source§

fn shl_assign(&mut self, rhs: u32)

Performs the <<= operation. Read more
Source§

impl ShlAssign<u64> for U256

Source§

fn shl_assign(&mut self, rhs: u64)

Performs the <<= operation. Read more
Source§

impl ShlAssign<u128> for U256

Source§

fn shl_assign(&mut self, rhs: u128)

Performs the <<= operation. Read more
Source§

impl ShlAssign<usize> for U256

Source§

fn shl_assign(&mut self, rhs: usize)

Performs the <<= operation. Read more
Source§

impl Shr<i8> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i8) -> U256

Performs the >> operation. Read more
Source§

impl Shr<i16> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i16) -> U256

Performs the >> operation. Read more
Source§

impl Shr<i32> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i32) -> U256

Performs the >> operation. Read more
Source§

impl Shr<i64> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i64) -> U256

Performs the >> operation. Read more
Source§

impl Shr<i128> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: i128) -> U256

Performs the >> operation. Read more
Source§

impl Shr<isize> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: isize) -> U256

Performs the >> operation. Read more
Source§

impl Shr<u8> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u8) -> U256

Performs the >> operation. Read more
Source§

impl Shr<u16> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u16) -> U256

Performs the >> operation. Read more
Source§

impl Shr<u32> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u32) -> U256

Performs the >> operation. Read more
Source§

impl Shr<u64> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u64) -> U256

Performs the >> operation. Read more
Source§

impl Shr<u128> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u128) -> U256

Performs the >> operation. Read more
Source§

impl Shr<usize> for U256

Source§

type Output = U256

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: usize) -> U256

Performs the >> operation. Read more
Source§

impl ShrAssign<i8> for U256

Source§

fn shr_assign(&mut self, rhs: i8)

Performs the >>= operation. Read more
Source§

impl ShrAssign<i16> for U256

Source§

fn shr_assign(&mut self, rhs: i16)

Performs the >>= operation. Read more
Source§

impl ShrAssign<i32> for U256

Source§

fn shr_assign(&mut self, rhs: i32)

Performs the >>= operation. Read more
Source§

impl ShrAssign<i64> for U256

Source§

fn shr_assign(&mut self, rhs: i64)

Performs the >>= operation. Read more
Source§

impl ShrAssign<i128> for U256

Source§

fn shr_assign(&mut self, rhs: i128)

Performs the >>= operation. Read more
Source§

impl ShrAssign<isize> for U256

Source§

fn shr_assign(&mut self, rhs: isize)

Performs the >>= operation. Read more
Source§

impl ShrAssign<u8> for U256

Source§

fn shr_assign(&mut self, rhs: u8)

Performs the >>= operation. Read more
Source§

impl ShrAssign<u16> for U256

Source§

fn shr_assign(&mut self, rhs: u16)

Performs the >>= operation. Read more
Source§

impl ShrAssign<u32> for U256

Source§

fn shr_assign(&mut self, rhs: u32)

Performs the >>= operation. Read more
Source§

impl ShrAssign<u64> for U256

Source§

fn shr_assign(&mut self, rhs: u64)

Performs the >>= operation. Read more
Source§

impl ShrAssign<u128> for U256

Source§

fn shr_assign(&mut self, rhs: u128)

Performs the >>= operation. Read more
Source§

impl ShrAssign<usize> for U256

Source§

fn shr_assign(&mut self, rhs: usize)

Performs the >>= operation. Read more
Source§

impl StructuralPartialEq for U256

Source§

impl Sub for U256

Source§

type Output = U256

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: U256) -> U256

Performs the - operation. Read more
Source§

impl SubAssign for U256

Source§

fn sub_assign(&mut self, rhs: U256)

Performs the -= operation. Read more
Source§

impl TryFrom<I256> for U256

Source§

fn try_from(n: I256) -> Result<U256, <U256 as TryFrom<I256>>::Error>

Fails for negative values. Use I256::cast_unsigned to reinterpret those bits instead.

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

impl TryFrom<U256> for I256

Source§

fn try_from(n: U256) -> Result<I256, <I256 as TryFrom<U256>>::Error>

Fails for values above 2^255 - 1, which would land on a negative I256. Use U256::cast_signed to reinterpret those bits instead.

Source§

type Error = TryFromIntError

The type returned in the event of a conversion error.
Source§

impl UpperHex for U256

Available on crate feature fmt only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl WriteXDR for U256

Source§

fn write_xdr<F, W>(&self, w: &mut W) -> Result<(), WriteError>
where W: Writer<F>,

Writes this value as XDR data to the writer. Read more
Source§

unsafe fn write_xdr_unchecked<F, W>(&self, w: &mut W)
where W: WriterUnchecked<F>,

Writes this value as XDR data to the writer, without runtime checks. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Context for T
where T: Any + Display,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Hash for T
where T: WriteXDR,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ReadXDROwned for T
where T: for<'r> ReadXDR<'r>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> StaticIfNoAlloc for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.