Trait mqtt::encodable::Decodable

source ·
pub trait Decodable: Sized {
    type Error: Error;
    type Cond;

    // Required method
    fn decode_with<R: Read>(
        reader: &mut R,
        cond: Self::Cond
    ) -> Result<Self, Self::Error>;

    // Provided method
    fn decode<R: Read>(reader: &mut R) -> Result<Self, Self::Error>
       where Self::Cond: Default { ... }
}
Expand description

Methods for decoding bytes to an Object according to MQTT specification

Required Associated Types§

Required Methods§

source

fn decode_with<R: Read>( reader: &mut R, cond: Self::Cond ) -> Result<Self, Self::Error>

Decodes object with additional data (or hints)

Provided Methods§

source

fn decode<R: Read>(reader: &mut R) -> Result<Self, Self::Error>
where Self::Cond: Default,

Decodes object from reader

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Decodable for ()

§

type Error = Infallible

§

type Cond = ()

source§

fn decode_with<R: Read>(_: &mut R, _: ()) -> Result<(), Self::Error>

source§

impl Decodable for String

§

type Error = Error

§

type Cond = ()

source§

fn decode_with<R: Read>(reader: &mut R, _rest: ()) -> Result<String, Error>

source§

impl Decodable for Vec<u8>

§

type Error = Error

§

type Cond = Option<u32>

source§

fn decode_with<R: Read>( reader: &mut R, length: Option<u32> ) -> Result<Vec<u8>, Error>

Implementors§