Trait SerdeFormat
pub trait SerdeFormat:
Send
+ Sync
+ 'static {
// Required methods
fn serialize<T>(
item: &T,
buf: &mut EncodeBuf<'_>,
) -> Result<(), Box<dyn Error + Sync + Send>>
where T: Serialize;
fn deserialize<T>(
buf: &mut DecodeBuf<'_>,
) -> Result<T, Box<dyn Error + Sync + Send>>
where T: DeserializeOwned;
}Available on crate features
grpc and http and serde and std only.Expand description
The wire format used by a SerdeCodec.
The JsonFormat in crate implements this trait for JSON,
and is the reference for implementing it for another format.
Required Methods§
fn serialize<T>(
item: &T,
buf: &mut EncodeBuf<'_>,
) -> Result<(), Box<dyn Error + Sync + Send>>where
T: Serialize,
fn serialize<T>(
item: &T,
buf: &mut EncodeBuf<'_>,
) -> Result<(), Box<dyn Error + Sync + Send>>where
T: Serialize,
Serialize item into buf.
fn deserialize<T>(
buf: &mut DecodeBuf<'_>,
) -> Result<T, Box<dyn Error + Sync + Send>>where
T: DeserializeOwned,
fn deserialize<T>(
buf: &mut DecodeBuf<'_>,
) -> Result<T, Box<dyn Error + Sync + Send>>where
T: DeserializeOwned,
Deserialize a message from buf, which contains exactly one full message.
The buffer has to be consumed: whatever is left in it is read back as the start of the next message.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".