pub trait Codec {
type Error;
// Required methods
fn encode<S>(msg: S) -> Result<Vec<u8>, Self::Error>
where S: Serialize;
fn decode<R>(buf: Vec<u8>) -> Result<R, Self::Error>
where R: DeserializeOwned;
}
Expand description
Trait for encoding and decoding WebSocket messages.
This allows you to customize how messages are encoded when sent over the wire.
Required Associated Types§
Required Methods§
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.