Enum mqttrust_core::Packet [−][src]
pub enum Packet<'a> { }
Expand description
Base enum for all MQTT packet types.
This is the main type you’ll be interacting with, as an output of decode_slice()
and an input of
encode()
. Most variants can be constructed directly without using methods.
// Simplest form let pkt = Packet::Connack(Connack { session_present: false, code: ConnectReturnCode::Accepted }); // Using `Into` trait let publish = Publish { dup: false, qospid: QosPid::AtMostOnce, retain: false, topic_name: "to/pic", payload: b"payload" }; let pkt: Packet = publish.into(); // Identifyer-only packets let pkt = Packet::Puback(Pid::try_from(42).unwrap());
Variants
Connect(Connect<'a>)
Connack(Connack)
Publish(Publish<'a>)
Puback(Pid)
Pubrec(Pid)
Pubrel(Pid)
Pubcomp(Pid)
Subscribe(Subscribe)
Suback(Suback)
Unsubscribe(Unsubscribe)
Unsuback(Pid)
Implementations
Return the packet type variant.
This can be used for matching, categorising, debuging, etc. Most users will match directly
on Packet
instead.
Trait Implementations
Performs the conversion.