Module serde_bincode_compat
Expand description
Bincode-compatible serde implementations for common abstracted types in Reth.
bincode
crate doesn’t work with optionally serializable serde fields, but some of the
Reth types require optional serialization for RPC compatibility. This module makes so that
all fields are serialized.
Read more: https://github.com/bincode-org/bincode/issues/326 Bincode compatibility support for reth primitive types.
This module provides traits and implementations to work around bincode’s limitations
with optional serde fields. The bincode crate requires all fields to be present during
serialization, which conflicts with types that have #[serde(skip_serializing_if)]
attributes for RPC compatibility.
§Overview
The main trait is SerdeBincodeCompat
, which provides a conversion mechanism between
types and their bincode-compatible representations. There are two main ways to implement
this trait:
- Using RLP encoding - Implement
RlpBincode
for types that already support RLP - Custom implementation - Define a custom representation type
§Examples
§Using with serde_with
#[serde_as]
#[derive(Serialize, Deserialize)]
struct MyStruct {
#[serde_as(as = "serde_bincode_compat::BincodeReprFor<'_, Header>")]
data: Header,
}
Structs§
- Block
- Bincode-compatible [
alloy_consensus::Block
] serde implementation. - Block
Body - Bincode-compatible [
alloy_consensus::BlockBody
] serde implementation. - Recovered
Block - Bincode-compatible
super::RecoveredBlock
serde implementation. - Sealed
Block - Bincode-compatible
super::SealedBlock
serde implementation. - Sealed
Header - Bincode-compatible
super::SealedHeader
serde implementation.
Traits§
- RlpBincode
- A helper trait for using RLP-encoding for providing bincode-compatible serialization.
- Serde
Bincode Compat - Trait for types that can be serialized and deserialized using bincode.
Type Aliases§
- Bincode
Repr For - Type alias for the
SerdeBincodeCompat::BincodeRepr
associated type.