Skip to main content
myrmic.dev

Decoder

Trait Decoder 

Source
pub trait Decoder: Sized {
    // Required method
    fn from_bytes(bytes: Bytes) -> Result<Self>;

    // Provided method
    fn from_args(length: usize) -> Result<Self> { ... }
}
Expand description

Turns a raw payload buffer into Self.

Message types get this for free via #[derive(Message)], which delegates to the bound Codec. The #[cmd]/#[evt] handler macros call from_args on the handler’s argument type.

Required Methods§

Source

fn from_bytes(bytes: Bytes) -> Result<Self>

Decodes Self from the raw payload buffer.

Provided Methods§

Source

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§

Source§

impl Decoder for Map<String, Value>

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for Number

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for bool

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for char

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for f32

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for f64

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for i8

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for i16

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for i32

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for i64

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for i128

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for u8

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for u16

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for u32

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for u64

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl Decoder for u128

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Source§

impl<T: Decoder> Decoder for Option<T>

Source§

fn from_args(length: usize) -> Result<Self>

Source§

fn from_bytes(bytes: Bytes) -> Result<Self>

Implementors§

Source§

impl Decoder for Bytes

Raw, uncodec’d bytes — a handler parameter of type Bytes receives the payload verbatim.

Source§

impl Decoder for CellLost

Source§

impl Decoder for Connection

Source§

impl Decoder for Disconnect

Source§

impl Decoder for DiscoveredDevice

Source§

impl Decoder for Notification

Source§

impl Decoder for ReadOutcome

Source§

impl Decoder for Sri

Source§

impl Decoder for String

Source§

impl Decoder for Value

Source§

impl Decoder for Void

Source§

impl Decoder for WriteOutcome

Source§

impl<T> Decoder for Callback<T>