Skip to main content

RlpEncode

Trait RlpEncode 

Source
pub trait RlpEncode {
    type Error;

    // Required methods
    fn encoded_rlp_len(&self) -> Result<usize, Self::Error>;
    fn encode_rlp(&self, output: &mut [u8]) -> Result<usize, Self::Error>;
}
Expand description

RLP encoding contract for derive-generated and hand-written domains.

Implementations must return the exact encoded length and must not modify the output buffer when they reject before writing.

Aggregate encoders, including derive-generated struct encoders, may already have written a valid prefix when a later field encoder returns an error or reports an inconsistent byte count. Callers must treat the returned length as authoritative and must discard the output buffer on any error.

Required Associated Types§

Source

type Error

Error returned by this encoder.

Required Methods§

Source

fn encoded_rlp_len(&self) -> Result<usize, Self::Error>

Returns the exact canonical RLP encoded length.

Source

fn encode_rlp(&self, output: &mut [u8]) -> Result<usize, Self::Error>

Canonically encodes self into output.

Returns the number of bytes written.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl RlpEncode for u64

Source§

type Error = DecodeError

Source§

fn encoded_rlp_len(&self) -> Result<usize, Self::Error>

Source§

fn encode_rlp(&self, output: &mut [u8]) -> Result<usize, Self::Error>

Source§

impl RlpEncode for u128

Source§

type Error = DecodeError

Source§

fn encoded_rlp_len(&self) -> Result<usize, Self::Error>

Source§

fn encode_rlp(&self, output: &mut [u8]) -> Result<usize, Self::Error>

Source§

impl<const N: usize> RlpEncode for [u8; N]

Source§

type Error = DecodeError

Source§

fn encoded_rlp_len(&self) -> Result<usize, Self::Error>

Source§

fn encode_rlp(&self, output: &mut [u8]) -> Result<usize, Self::Error>

Implementors§