pub trait Encoder<Item = Self> {
type Error;
// Required methods
fn encode(item: &Item, buf: &mut BytesMut) -> Result<(), Self::Error>;
fn size_of(item: &Item) -> usize;
}Expand description
A trait to be implemented by types that encode [Item] values into a
buffer of type BytesMut.
Required Associated Types§
Required Methods§
sourcefn encode(item: &Item, buf: &mut BytesMut) -> Result<(), Self::Error>
fn encode(item: &Item, buf: &mut BytesMut) -> Result<(), Self::Error>
Encodes the given input into the output buffer.
Arguments
item- The input to encode.buf- The output buffer to write the encoded input to.