Trait mqtt::packet::Packet [−][src]
pub trait Packet: Sized { type Payload: Encodable + Decodable; fn fixed_header(&self) -> &FixedHeader; fn payload(self) -> Self::Payload; fn payload_ref(&self) -> &Self::Payload; fn encode_variable_headers<W: Write>(
&self,
writer: &mut W
) -> Result<(), PacketError<Self>>; fn encoded_variable_headers_length(&self) -> u32; fn decode_packet<R: Read>(
reader: &mut R,
fixed_header: FixedHeader
) -> Result<Self, PacketError<Self>>; }
Methods for encoding and decoding a packet
Associated Types
Required Methods
fn fixed_header(&self) -> &FixedHeader
Get a FixedHeader
of this packet
fn payload(self) -> Self::Payload
Get the payload
fn payload_ref(&self) -> &Self::Payload
Get a borrow of payload
fn encode_variable_headers<W: Write>(
&self,
writer: &mut W
) -> Result<(), PacketError<Self>>
&self,
writer: &mut W
) -> Result<(), PacketError<Self>>
Encode variable headers to writer
fn encoded_variable_headers_length(&self) -> u32
Length of bytes after encoding variable header
fn decode_packet<R: Read>(
reader: &mut R,
fixed_header: FixedHeader
) -> Result<Self, PacketError<Self>>
reader: &mut R,
fixed_header: FixedHeader
) -> Result<Self, PacketError<Self>>
Deocde packet with a FixedHeader
Implementors
impl Packet for ConnectPacket type Payload = ConnectPacketPayload;
impl Packet for ConnackPacket type Payload = ();
impl Packet for PublishPacket type Payload = Vec<u8>;
impl Packet for PubackPacket type Payload = ();
impl Packet for PubrecPacket type Payload = ();
impl Packet for PubrelPacket type Payload = ();
impl Packet for PubcompPacket type Payload = ();
impl Packet for PingreqPacket type Payload = ();
impl Packet for PingrespPacket type Payload = ();
impl Packet for DisconnectPacket type Payload = ();
impl Packet for SubscribePacket type Payload = SubscribePacketPayload;
impl Packet for SubackPacket type Payload = SubackPacketPayload;
impl Packet for UnsubackPacket type Payload = ();
impl Packet for UnsubscribePacket type Payload = UnsubscribePacketPayload;