January 2018
Beginner to intermediate
454 pages
10h 8m
English
Let's now see how to encode data; it's even simpler:
impl Encoder for BytesCodec { type Item = Vec<u8>; type Error = io::Error; fn encode(&mut self, data: Vec<u8>, buf: &mut BytesMut) -> io::Result<()> { buf.extend(data); Ok(()) } }
We just extend the buffer with the data.