Debian Codegraph @

src/encoder.rs

raw symbols SCIP
1 use super::fuse::Fuse;
2 use bytes::BytesMut;
3 use std::io::Error;
4
5 /// Encoding of messages as bytes, for use with `FramedWrite`.
6 pub trait Encoder {
7 /// The type of items consumed by `encode`
8 type Item;
9 /// The type of encoding errors.
10 type Error: From<Error>;
11
12 /// Encodes an item into the `BytesMut` provided by dst.
13 fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error>;
14 }
15
16 impl<T, U: Encoder> Encoder for Fuse<T, U> {
17 type Item = U::Item;
18 type Error = U::Error;
19
20 fn encode(&mut self, item: Self::Item, dst: &mut BytesMut) -> Result<(), Self::Error> {
21 self.u.encode(item, dst)
22 }
23 }