channels_io/framed/
encoder.rs

1use alloc::vec::Vec;
2
3/// Encode an item into a buffer of bytes.
4pub trait Encoder {
5	/// The type of items the encoder accepts.
6	type Item;
7
8	/// Error type returned by the encoder.
9	type Error;
10
11	/// Encode `item` into `buf`.
12	///
13	/// Implementations should only append data to `buf`. Additionally, it is not guaranteed
14	/// that `buf` is empty on each call of this method.
15	fn encode(
16		&mut self,
17		item: Self::Item,
18		buf: &mut Vec<u8>,
19	) -> Result<(), Self::Error>;
20}