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.
The payload helper re-validates canonicality as part of its public API
contract. For a correctly constructed RlpInteger, this validation
was already enforced by Self::try_from_scalar.
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.
The payload helper re-validates canonicality as part of its public API
contract. For a correctly constructed RlpInteger, this validation
was already enforced by Self::try_from_scalar.
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.
The payload helper re-validates canonicality as part of its public API
contract. For a correctly constructed RlpInteger, this validation
was already enforced by Self::try_from_scalar.
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>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
self and other values to be equal, and is used by ==.