pub trait Codec: Sized {
type Error;
// Required methods
fn encoded_size(&self) -> usize;
unsafe fn encode_in(&self, out: &mut [u8]) -> usize;
fn decode(out: &[u8]) -> Result<WithSize<Self>, WithOffset<Self::Error>>;
// Provided method
fn encode(&self) -> Box<[u8]> { ... }
}
Expand description
Trait implemented by any item that is encodable to a byte array and decodable from a byte array.
Required Associated Types§
Required Methods§
sourcefn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Computes the number of bytes required to encode the item.
Provided Methods§
Object Safety§
This trait is not object safe.