pub trait Encoder<B, Item = Self> {
type Error;
// Required methods
fn encode(item: &Item, buf: &mut B) -> Result<(), Self::Error>;
fn size_of(item: &Item, buf: &B) -> usize;
}Expand description
A trait to be implemented by types that encode [Item] values into a
buffer of type [B].
Required Associated Types§
Required Methods§
Sourcefn encode(item: &Item, buf: &mut B) -> Result<(), Self::Error>
fn encode(item: &Item, buf: &mut B) -> Result<(), Self::Error>
Encodes the given input into the output buffer.
This method does not return a result because calls to
Encoder::encode never do.
§Arguments
item- The input to encode.buf- The output buffer to write the encoded input to.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.