pub trait Codec {
// Required methods
fn encode(msg: &Message) -> Vec<u8> ⓘ;
fn decode(buf: &[u8]) -> Result<Message, DecodeError>;
}Expand description
Codec trait for serialising and deserialising Messages.
Required Methods§
Sourcefn decode(buf: &[u8]) -> Result<Message, DecodeError>
fn decode(buf: &[u8]) -> Result<Message, DecodeError>
Decode a byte-slice into a Message.
§Errors
Returns DecodeError if the bytes are invalid for this codec.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".