pub trait Encode<T: ?Sized> {
type Error;
type Encoder<'a>: Encoder
where T: 'a;
// Required method
fn encode<'a>(&self, t: &'a T) -> Result<Self::Encoder<'a>, Self::Error>;
}Expand description
The trait encodes the type to the bytes and passes it to the Encoder,
which stores it and provides a reference to it. That allows gives more
flexibility and more performant encoding, allowing the use of slices and arrays
instead of vectors in some cases. Since the Encoder returns Cow<[u8]>,
it is always possible to take ownership of the serialized value.
Required Associated Types§
Required Methods§
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.