Skip to main content

Codec

Trait Codec 

Source
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§

Source

fn encode(msg: &Message) -> Vec<u8>

Encode a high-level Message into a byte-vector.

Source

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".

Implementors§