pub trait Codec<W>: Send + Sync {
type Message: Send + Sync;
type Error;
// Required methods
fn encode(
&self,
src: &Self::Message,
dst: &mut W,
) -> Result<usize, Self::Error>;
fn decode(
&self,
src: &mut W,
) -> Result<Option<(usize, Self::Message)>, Self::Error>;
}Expand description
Encodes and decodes messages from a wire-level type.
W is the wire type (e.g. ByteBuffer, ws::Message).
Message is the application-level type.