pub struct U256(/* private fields */);Expand description
256-bit integer for Bitcoin target / chainwork calculations (256-bit limb layout).
Implementations§
Source§impl U256
impl U256
pub fn zero() -> U256
Sourcepub fn to_le_bytes(&self) -> [u8; 32]
pub fn to_le_bytes(&self) -> [u8; 32]
Serialize as 32 little-endian bytes (Bitcoin uint256 wire layout).
Sourcepub fn gbt_target_hex(&self) -> String
pub fn gbt_target_hex(&self) -> String
Bitcoin RPC GetHex() / getblocktemplate target (byte-reversed display hex).
pub fn one() -> U256
pub fn is_zero(&self) -> bool
pub fn not(self) -> U256
pub fn checked_add(self, other: U256) -> Option<U256>
pub fn saturating_add(self, other: U256) -> U256
Sourcepub fn div(self, divisor: U256) -> U256
pub fn div(self, divisor: U256) -> U256
Full-width unsigned division for 256-bit chainwork arithmetic.
Sourcepub fn to_be_bytes(self) -> [u8; 32]
pub fn to_be_bytes(self) -> [u8; 32]
Serialize as 32 big-endian bytes (Bitcoin RPC chainwork display order).
Sourcepub fn from_be_bytes(bytes: &[u8; 32]) -> U256
pub fn from_be_bytes(bytes: &[u8; 32]) -> U256
Parse 32 big-endian bytes (RPC / chainstate cache layout).
Trait Implementations§
impl Copy for U256
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
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
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
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.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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