pub trait Wire<'de>: Sized {
// Required methods
fn decode(
src: &'de [u8],
pos: usize,
ctx: &Ctx,
) -> Result<(Self, usize), ProtoError>;
fn encode(&self, dst: &mut Vec<u8>, ctx: &Ctx);
fn encoded_len(&self) -> usize;
}Expand description
Codec trait for fixed-layout and variable-layout on-wire structures.
The 'de lifetime ties decoded variable-length data (names, blobs) to
the input buffer, enabling zero-copy parsing.
Required Methods§
Sourcefn decode(
src: &'de [u8],
pos: usize,
ctx: &Ctx,
) -> Result<(Self, usize), ProtoError>
fn decode( src: &'de [u8], pos: usize, ctx: &Ctx, ) -> Result<(Self, usize), ProtoError>
Decode one instance starting at pos within src.
Returns the parsed value and the offset immediately past it.
Variable-length fields are borrowed from src.
Sourcefn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Number of bytes this value occupies in its encoded form.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".