Skip to main content

FrameCodec

Trait FrameCodec 

Source
pub trait FrameCodec {
    type Record;

    // Required methods
    fn encode(record: &Self::Record) -> Vec<u8> ;
    fn decode(payload: &[u8]) -> Result<Self::Record>;
}
Expand description

Serialization seam: how one record becomes a frame payload and back.

encode is infallible because the codecs we use (protobuf, JSON over plain owned types) cannot fail in practice; a codec with fallible encoding should surface that as an io::Error from a panic-documented invariant instead.

Required Associated Types§

Source

type Record

The record type carried in each frame.

Required Methods§

Source

fn encode(record: &Self::Record) -> Vec<u8>

Serialize a record into a frame payload.

Source

fn decode(payload: &[u8]) -> Result<Self::Record>

Deserialize a frame payload back into a record.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§