pub trait ExactCodec: Sized {
// Required methods
fn write(&self, out: &mut Vec<u8>);
fn read(buf: &[u8], pos: &mut usize) -> Option<Self>;
// Provided methods
fn to_bytes(&self) -> Vec<u8> ⓘ { ... }
fn from_bytes(buf: &[u8]) -> Option<Self> { ... }
}Expand description
A canonical, self-delimiting byte encoding. See the module documentation.
Required Methods§
Provided Methods§
fn to_bytes(&self) -> Vec<u8> ⓘ
Sourcefn from_bytes(buf: &[u8]) -> Option<Self>
fn from_bytes(buf: &[u8]) -> Option<Self>
The value buf canonically encodes, with nothing left over.
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.