pub trait Codec {
type SendItem;
type SendError;
type RecvItem;
type RecvError;
// Required methods
fn encoder(
&self,
) -> Box<dyn TypedEncoder<Self::SendItem, Error = Self::SendError> + Send + Sync>;
fn decoder(
&self,
) -> Box<dyn TypedDecoder<Item = Self::RecvItem, Error = Self::RecvError> + Send + Sync>;
}Expand description
Represents a specific encoding and decoding scheme for one side of a connection.
The codec defines what messages the user is spected to send to the other side, as well as the messages that are expected to be received from the other side.
The encoders and decoders generated by the Codec handle any optional transformations, such as compression, as configured during protocol negotiation.