channels_io/framed/decoder.rs
1use alloc::vec::Vec;
2
3/// Decode an item from a buffer of bytes.
4pub trait Decoder {
5 /// The type of items the decoder accepts.
6 type Output;
7
8 /// Error type returned by the decoder.
9 type Error;
10
11 /// Decode an item from `buf`.
12 ///
13 /// Implementations should remove data from `buf` as each item is decoded.
14 fn decode(
15 &mut self,
16 buf: &mut Vec<u8>,
17 ) -> Result<Option<Self::Output>, Self::Error>;
18}