pub trait WireEncode {
// Required methods
fn encode(&self, buf: &mut BytesMut);
fn encoded_size(&self) -> usize;
// Provided method
fn to_bytes(&self) -> Bytes { ... }
}Expand description
Encode a wire type into a caller-owned buffer.
Buffer-first design: the caller controls allocation. The to_bytes()
convenience method allocates when needed, but hot paths can reuse
buffers via encode() directly.
Required Methods§
Sourcefn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Return the exact encoded size in bytes.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".