Enum Packet
pub enum Packet<'a> {
Show 15 variants
Connect(Connect<'a>),
Connack(Connack<'a>),
Publish(ReceivedPublish<'a>),
Puback(Ack<'a>),
Pubrec(Ack<'a>),
Pubrel(Ack<'a>),
Pubcomp(Ack<'a>),
Subscribe(Subscribe<'a>),
Suback(Suback<'a>),
Unsubscribe(Unsubscribe<'a>),
Unsuback(Unsuback<'a>),
Pingreq,
Pingresp,
Disconnect(Disconnect<'a>),
Auth(Auth<'a>),
}Expand description
A decoded MQTT v5 packet. All borrowed data refers to the input buffer.
Variants§
Connect(Connect<'a>)
Client request to connect to the server.
Connack(Connack<'a>)
Server acknowledgement of a connection request.
Publish(ReceivedPublish<'a>)
A received PUBLISH. To send one, write a Publish with
PacketWriter::write.
Puback(Ack<'a>)
Publish acknowledgement (QoS 1).
Pubrec(Ack<'a>)
Publish received (QoS 2, step 1).
Pubrel(Ack<'a>)
Publish release (QoS 2, step 2).
Pubcomp(Ack<'a>)
Publish complete (QoS 2, step 3).
Subscribe(Subscribe<'a>)
Subscribe request.
Suback(Suback<'a>)
Subscribe acknowledgement.
Unsubscribe(Unsubscribe<'a>)
Unsubscribe request.
Unsuback(Unsuback<'a>)
Unsubscribe acknowledgement.
Pingreq
Ping request.
Pingresp
Ping response.
Disconnect(Disconnect<'a>)
Disconnect notification.
Auth(Auth<'a>)
Authentication exchange.
Implementations§
§impl<'a> Packet<'a>
impl<'a> Packet<'a>
pub fn decode(header: FixedHeader, data: &'a [u8]) -> Result<Self, DecodeError>
pub fn decode(header: FixedHeader, data: &'a [u8]) -> Result<Self, DecodeError>
Decodes a packet from the variable header + payload bytes.
header is the already-parsed fixed header.
§Errors
Returns DecodeError if the data is malformed or its length or field
values are invalid.
pub fn measure(&self) -> Option<Measured<'_, Self>>
pub fn measure(&self) -> Option<Measured<'_, Self>>
Measures the packet for encoding. Returns None if the Remaining
Length exceeds the Variable Byte Integer maximum, about 256 MiB.
pub fn encoded_len(&self) -> Option<usize>
pub fn encoded_len(&self) -> Option<usize>
Total encoded size of this packet in bytes, fixed header included.
Returns None if the packet is too large to encode.
pub fn encode<S: Sink>(&self, sink: S) -> Result<(), EncodeError<S::Error>>
pub fn encode<S: Sink>(&self, sink: S) -> Result<(), EncodeError<S::Error>>
Encodes the complete packet into sink.
§Errors
Returns EncodeError::TooLarge if the Remaining Length exceeds the
Variable Byte Integer maximum, or EncodeError::Sink if the sink
fails.