Skip to main content

Body

Trait Body 

pub trait Body {
    // Required methods
    fn encode_body<S: Sink>(&self, w: &mut Writer<S>) -> Result<(), S::Error>;
    fn header_byte(&self) -> u8;
}
Expand description

The variable header and payload of a control packet, with its fixed header byte.

Packet and Publish implement it. Another implementation must write a body that is valid for its header byte.

Required Methods§

fn encode_body<S: Sink>(&self, w: &mut Writer<S>) -> Result<(), S::Error>

Writes the variable header and payload.

§Errors

Returns the sink’s error if it cannot take the bytes.

fn header_byte(&self) -> u8

The first byte of the fixed header: packet type and flags.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl Body for Packet<'_>

§

impl Body for Publish<'_>