MqttPacket

Trait MqttPacket 

Source
pub trait MqttPacket: Sized {
    // Required methods
    fn packet_type(&self) -> PacketType;
    fn encode_body<B: BufMut>(&self, buf: &mut B) -> Result<()>;
    fn decode_body<B: Buf>(
        buf: &mut B,
        fixed_header: &FixedHeader,
    ) -> Result<Self>;

    // Provided methods
    fn flags(&self) -> u8 { ... }
    fn encode<B: BufMut>(&self, buf: &mut B) -> Result<()> { ... }
}
Expand description

Trait for MQTT packets

Required Methods§

Source

fn packet_type(&self) -> PacketType

Returns the packet type

Source

fn encode_body<B: BufMut>(&self, buf: &mut B) -> Result<()>

Encodes the packet body (without fixed header)

§Errors

Returns an error if encoding fails

§Errors

Returns an error if the operation fails

Source

fn decode_body<B: Buf>(buf: &mut B, fixed_header: &FixedHeader) -> Result<Self>

Decodes the packet body (without fixed header)

§Errors

Returns an error if decoding fails

Provided Methods§

Source

fn flags(&self) -> u8

Returns the fixed header flags

Source

fn encode<B: BufMut>(&self, buf: &mut B) -> Result<()>

Encodes the complete packet (with fixed header)

§Errors

Returns an error if encoding fails

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.

Implementors§