Trait Encodable

Source
pub trait Encodable {
    // Required methods
    fn encode<W: Write>(&self, writer: &mut W) -> Result<()>;
    fn encoded_length(&self) -> u32;
}
Expand description

Methods for encoding an Object to bytes according to MQTT specification

Required Methods§

Source

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Encodes to writer

Source

fn encoded_length(&self) -> u32

Length of bytes after encoded

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Encodable for ()

Source§

fn encode<W: Write>(&self, _: &mut W) -> Result<(), Error>

Source§

fn encoded_length(&self) -> u32

Source§

impl Encodable for String

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn encoded_length(&self) -> u32

Source§

impl Encodable for Vec<u8>

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn encoded_length(&self) -> u32

Source§

impl<'a> Encodable for &'a str

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn encoded_length(&self) -> u32

Source§

impl<'a> Encodable for &'a [u8]

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<(), Error>

Source§

fn encoded_length(&self) -> u32

Source§

impl<T: Encodable> Encodable for Option<T>

Source§

fn encode<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

fn encoded_length(&self) -> u32

Implementors§