Trait Encode

Source
pub trait Encode {
    type Item: Sized;

    // Required method
    fn encode(&mut self, value: Self::Item, buf: &mut Buf);
}
Expand description

A trait for encoding frames into a byte buffer.

This trait is used as a building block of Framed to define how frames are encoded into bytes to get passed to the underlying byte stream. each frame written to Framed will be encoded with this trait to an internal buffer. That buffer is then written out when possible to the underlying I/O stream.

Required Associated Types§

Source

type Item: Sized

Value to encode

Required Methods§

Source

fn encode(&mut self, value: Self::Item, buf: &mut Buf)

Encodes a frame into the buffer provided.

This method will encode msg into the byte buffer provided by buf. The buf provided is an internal buffer of the Framed instance and will be written out when possible.

Implementors§