Trait tk_bufstream::Encode
[−]
[src]
pub trait Encode { type Item: Sized; fn encode(&mut self, value: Self::Item, buf: &mut Buf); }
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.
Associated Types
Required Methods
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.