pub trait Decoder: Sized {
// Required method
fn from_bytes(bytes: Bytes) -> Result<Self>;
// Provided method
fn from_args(length: usize) -> Result<Self> { ... }
}Expand description
Required Methods§
Sourcefn from_bytes(bytes: Bytes) -> Result<Self>
fn from_bytes(bytes: Bytes) -> Result<Self>
Decodes Self from the raw payload buffer.
Provided Methods§
Sourcefn from_args(length: usize) -> Result<Self>
fn from_args(length: usize) -> Result<Self>
Reads this invocation’s length-byte payload from the host (via
get_arguments) and decodes it with
from_bytes.
A failure on an empty buffer is reported as a missing payload instead: a decoder for a mandatory payload can only describe absence as malformed input, which points at nothing the handler’s author can act on.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Implementors§
impl Decoder for Bytes
Raw, uncodec’d bytes — a handler parameter of type Bytes receives the
payload verbatim.