pub trait FrameCodec:
Send
+ Sync
+ 'static {
type Frame: Send + Sync + 'static;
type Decoder: Decoder<Item = Self::Frame, Error = Error> + Send;
type Encoder: Encoder<Self::Frame, Error = Error> + Send;
// Required methods
fn decoder(&self) -> Self::Decoder;
fn encoder(&self) -> Self::Encoder;
fn frame_payload(frame: &Self::Frame) -> &[u8] ⓘ;
fn wrap_payload(payload: Vec<u8>) -> Self::Frame;
fn max_frame_length(&self) -> usize;
// Provided method
fn correlation_id(_frame: &Self::Frame) -> Option<u64> { ... }
}Expand description
Trait for pluggable frame codecs supporting different wire protocols.
Implementors define their own Frame type (for example, a struct carrying
transaction identifiers) and provide decoder/encoder instances.
Required Associated Types§
Required Methods§
Sourcefn frame_payload(frame: &Self::Frame) -> &[u8] ⓘ
fn frame_payload(frame: &Self::Frame) -> &[u8] ⓘ
Extract the message payload bytes from a frame.
Sourcefn wrap_payload(payload: Vec<u8>) -> Self::Frame
fn wrap_payload(payload: Vec<u8>) -> Self::Frame
Wrap serialized payload bytes into a frame for sending.
Sourcefn max_frame_length(&self) -> usize
fn max_frame_length(&self) -> usize
Maximum frame length this codec will accept.
Provided Methods§
Sourcefn correlation_id(_frame: &Self::Frame) -> Option<u64>
fn correlation_id(_frame: &Self::Frame) -> Option<u64>
Extract correlation ID for request/response matching.
Returns None for protocols without correlation (for example, RESP).
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.