Trait SerdeBincodeCompat

pub trait SerdeBincodeCompat: Sized + 'static {
    type BincodeRepr<'a>: Debug + Serialize + DeserializeOwned;

    // Required methods
    fn as_repr(&self) -> Self::BincodeRepr<'_>;
    fn from_repr(repr: Self::BincodeRepr<'_>) -> Self;
}
Expand description

Trait for types that can be serialized and deserialized using bincode.

This trait provides a workaround for bincode’s incompatibility with optional serde fields. It ensures all fields are serialized, making the type bincode-compatible.

§Implementation

The easiest way to implement this trait is using RlpBincode for RLP-encodable types:

impl RlpBincode for MyType {}
// SerdeBincodeCompat is automatically implemented

For custom implementations, see the examples in the block module.

The recommended way to add bincode compatible serialization is via the serde_with crate and the serde_as macro. See for reference header.

Required Associated Types§

type BincodeRepr<'a>: Debug + Serialize + DeserializeOwned

Serde representation of the type for bincode serialization.

This type defines the bincode compatible serde format for the type.

Required Methods§

fn as_repr(&self) -> Self::BincodeRepr<'_>

Convert this type into its bincode representation

fn from_repr(repr: Self::BincodeRepr<'_>) -> Self

Convert from the bincode representation

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl SerdeBincodeCompat for EthereumTxEnvelope<TxEip4844>

§

type BincodeRepr<'a> = EthereumTxEnvelope<'a>

§

fn as_repr( &self, ) -> <EthereumTxEnvelope<TxEip4844> as SerdeBincodeCompat>::BincodeRepr<'_>

§

fn from_repr( repr: <EthereumTxEnvelope<TxEip4844> as SerdeBincodeCompat>::BincodeRepr<'_>, ) -> EthereumTxEnvelope<TxEip4844>

§

impl SerdeBincodeCompat for OpReceipt

§

type BincodeRepr<'a> = OpReceipt<'a>

§

fn as_repr(&self) -> <OpReceipt as SerdeBincodeCompat>::BincodeRepr<'_>

§

fn from_repr( repr: <OpReceipt as SerdeBincodeCompat>::BincodeRepr<'_>, ) -> OpReceipt

§

impl SerdeBincodeCompat for OpTxEnvelope

§

type BincodeRepr<'a> = OpTxEnvelope<'a>

§

fn as_repr(&self) -> <OpTxEnvelope as SerdeBincodeCompat>::BincodeRepr<'_>

§

fn from_repr( repr: <OpTxEnvelope as SerdeBincodeCompat>::BincodeRepr<'_>, ) -> OpTxEnvelope

§

impl<T, H> SerdeBincodeCompat for Block<T, H>

§

type BincodeRepr<'a> = Block<'a, T, H>

§

fn as_repr(&self) -> <Block<T, H> as SerdeBincodeCompat>::BincodeRepr<'_>

§

fn from_repr( repr: <Block<T, H> as SerdeBincodeCompat>::BincodeRepr<'_>, ) -> Block<T, H>

§

impl<T, H> SerdeBincodeCompat for BlockBody<T, H>

§

type BincodeRepr<'a> = BlockBody<'a, T, H>

§

fn as_repr(&self) -> <BlockBody<T, H> as SerdeBincodeCompat>::BincodeRepr<'_>

§

fn from_repr( repr: <BlockBody<T, H> as SerdeBincodeCompat>::BincodeRepr<'_>, ) -> BlockBody<T, H>

Implementors§

§

impl SerdeBincodeCompat for Header

§

type BincodeRepr<'a> = Header<'a>

§

impl SerdeBincodeCompat for Receipt

§

type BincodeRepr<'a> = Receipt<'a>

§

impl<B, T> SerdeBincodeCompat for Extended<B, T>

§

type BincodeRepr<'a> = ExtendedRepr<'a, B, T>

§

impl<H> SerdeBincodeCompat for SealedHeader<H>

§

type BincodeRepr<'a> = SealedHeader<'a, H>

§

impl<T> SerdeBincodeCompat for SealedBlock<T>
where T: Block + 'static, <T as Block>::Header: SerdeBincodeCompat, <T as Block>::Body: SerdeBincodeCompat,

§

type BincodeRepr<'a> = SealedBlock<'a, T>

§

impl<T> SerdeBincodeCompat for ExecutionOutcome<T>

§

impl<T> SerdeBincodeCompat for RecoveredBlock<T>
where T: Block + 'static, <T as Block>::Header: SerdeBincodeCompat, <T as Block>::Body: SerdeBincodeCompat,

§

type BincodeRepr<'a> = RecoveredBlock<'a, T>

§

impl<T> SerdeBincodeCompat for T
where T: RlpBincode + 'static,

§

type BincodeRepr<'a> = Bytes