pub struct ChainId(/* private fields */);Expand description
Ethereum chain identifier.
This type enforces canonical integer encoding only. EIP-155 assigns chain ID 0 to unsigned legacy transactions; signed transaction validation must reject chain ID 0 independently.
Implementations§
Source§impl ChainId
impl ChainId
Sourcepub fn encoded_rlp_len(self) -> Result<usize, PrimitiveRlpError>
pub fn encoded_rlp_len(self) -> Result<usize, PrimitiveRlpError>
Returns the canonical RLP encoded length.
Sourcepub fn encode_rlp(self, output: &mut [u8]) -> Result<usize, PrimitiveRlpError>
pub fn encode_rlp(self, output: &mut [u8]) -> Result<usize, PrimitiveRlpError>
Canonically encodes this value into output.
Returns the number of bytes written. output is not modified unless
this function returns Ok.
Sourcepub fn try_from_rlp(
input: &[u8],
limits: DecodeLimits,
) -> Result<Self, PrimitiveRlpError>
pub fn try_from_rlp( input: &[u8], limits: DecodeLimits, ) -> Result<Self, PrimitiveRlpError>
Decodes exactly one canonical RLP integer into this domain.
EIP-155 note: This function accepts ChainId(0), which is reserved
for unsigned legacy transactions. Callers that validate signed
transaction chain IDs must reject ChainId(0) independently; this
decoder does not enforce that constraint.
Sourcepub fn try_from_rlp_signed(
input: &[u8],
limits: DecodeLimits,
) -> Result<Self, PrimitiveRlpError>
pub fn try_from_rlp_signed( input: &[u8], limits: DecodeLimits, ) -> Result<Self, PrimitiveRlpError>
Decodes a signed EIP-155 transaction chain ID.
Rejects 0, which is reserved for unsigned legacy transactions and
must not be accepted as a signed transaction replay domain.
Source§impl ChainId
impl ChainId
Sourcepub fn try_from_canonical_be_slice(bytes: &[u8]) -> Result<Self, PrimitiveError>
pub fn try_from_canonical_be_slice(bytes: &[u8]) -> Result<Self, PrimitiveError>
Creates a value from a canonical RLP integer payload.
The empty payload represents zero. Non-empty payloads must be shortest-form unsigned big-endian bytes without a leading zero.
Source§impl ChainId
impl ChainId
Sourcepub fn try_from_signed_canonical_be_slice(
bytes: &[u8],
) -> Result<Self, PrimitiveError>
pub fn try_from_signed_canonical_be_slice( bytes: &[u8], ) -> Result<Self, PrimitiveError>
Creates a signed-transaction chain ID from a canonical RLP integer payload.
Rejects 0, which EIP-155 reserves for unsigned legacy transactions.
Trait Implementations§
impl Copy for ChainId
impl Eq for ChainId
Source§impl Ord for ChainId
impl Ord for ChainId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for ChainId
impl PartialOrd for ChainId
Source§impl RlpDecode for ChainId
impl RlpDecode for ChainId
Source§type Error = PrimitiveRlpError
type Error = PrimitiveRlpError
Source§fn decode_rlp(input: &[u8], limits: DecodeLimits) -> Result<Self, Self::Error>
fn decode_rlp(input: &[u8], limits: DecodeLimits) -> Result<Self, Self::Error>
input.