pub struct RlpInteger<'a> { /* private fields */ }Expand description
Borrowed canonical RLP integer.
Ethereum integers are encoded as shortest-form unsigned big-endian bytes. The empty payload represents zero. A non-empty payload whose first byte is zero is rejected.
Fields are private so downstream crates cannot construct unvalidated decoded values and feed them into trusted re-encoding paths.
Implementations§
Source§impl<'a> RlpInteger<'a>
impl<'a> RlpInteger<'a>
Sourcepub fn try_from_scalar(scalar: RlpScalar<'a>) -> Result<Self, DecodeError>
pub fn try_from_scalar(scalar: RlpScalar<'a>) -> Result<Self, DecodeError>
Validates a decoded RLP scalar as a canonical integer.
Sourcepub const fn encoded_len(self) -> usize
pub const fn encoded_len(self) -> usize
Returns the total encoded item length in bytes.
Sourcepub const fn header_len(self) -> usize
pub const fn header_len(self) -> usize
Returns the RLP header length in bytes.
Sourcepub const fn form(self) -> RlpScalarForm
pub const fn form(self) -> RlpScalarForm
Returns the canonical scalar form used by the integer encoding.
Sourcepub fn to_u64(self) -> Result<u64, DecodeError>
pub fn to_u64(self) -> Result<u64, DecodeError>
Converts this integer to u64 after checking the byte width.
Sourcepub fn to_u128(self) -> Result<u128, DecodeError>
pub fn to_u128(self) -> Result<u128, DecodeError>
Converts this integer to u128 after checking the byte width.
Sourcepub fn to_be_bytes32(self) -> Result<[u8; 32], DecodeError>
pub fn to_be_bytes32(self) -> Result<[u8; 32], DecodeError>
Converts this integer to right-aligned unsigned 256-bit bytes.
Trait Implementations§
Source§impl<'a> Clone for RlpInteger<'a>
impl<'a> Clone for RlpInteger<'a>
Source§fn clone(&self) -> RlpInteger<'a>
fn clone(&self) -> RlpInteger<'a>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for RlpInteger<'a>
Source§impl<'a> Debug for RlpInteger<'a>
impl<'a> Debug for RlpInteger<'a>
impl<'a> Eq for RlpInteger<'a>
Source§impl<'a> PartialEq for RlpInteger<'a>
impl<'a> PartialEq for RlpInteger<'a>
Source§fn eq(&self, other: &RlpInteger<'a>) -> bool
fn eq(&self, other: &RlpInteger<'a>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<'a> StructuralPartialEq for RlpInteger<'a>
Auto Trait Implementations§
impl<'a> Freeze for RlpInteger<'a>
impl<'a> RefUnwindSafe for RlpInteger<'a>
impl<'a> Send for RlpInteger<'a>
impl<'a> Sync for RlpInteger<'a>
impl<'a> Unpin for RlpInteger<'a>
impl<'a> UnsafeUnpin for RlpInteger<'a>
impl<'a> UnwindSafe for RlpInteger<'a>
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