Trait mqtt::packet::EncodablePacket
source · pub trait EncodablePacket {
// Required method
fn fixed_header(&self) -> &FixedHeader;
// Provided methods
fn encode_packet<W: Write>(&self, _writer: &mut W) -> Result<()> { ... }
fn encoded_packet_length(&self) -> u32 { ... }
}
Expand description
A trait representing a packet that can be encoded, when passed as FooPacket
or as
&FooPacket
. Different from Encodable
in that it prevents you from accidentally passing
a type intended to be encoded only as a part of a packet and doesn’t have a header, e.g.
Vec<u8>
.
Required Methods§
sourcefn fixed_header(&self) -> &FixedHeader
fn fixed_header(&self) -> &FixedHeader
Get a reference to FixedHeader
. All MQTT packet must have a fixed header.
Provided Methods§
sourcefn encode_packet<W: Write>(&self, _writer: &mut W) -> Result<()>
fn encode_packet<W: Write>(&self, _writer: &mut W) -> Result<()>
Encodes packet data after fixed header, including variable headers and payload
sourcefn encoded_packet_length(&self) -> u32
fn encoded_packet_length(&self) -> u32
Length in bytes for data after fixed header, including variable headers and payload
Object Safety§
This trait is not object safe.