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,
qos: QoS::AtMostOnce,
retain: false,
pid: None,
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>)
Tuple Fields of Connect
0: Connect<'a>
Connack(Connack)
Tuple Fields of Connack
0: Connack
Publish(Publish<'a>)
Tuple Fields of Publish
0: Publish<'a>
Puback(Pid)
Tuple Fields of Puback
0: Pid
Pubrec(Pid)
Tuple Fields of Pubrec
0: Pid
Pubrel(Pid)
Tuple Fields of Pubrel
0: Pid
Pubcomp(Pid)
Tuple Fields of Pubcomp
0: Pid
Subscribe(Subscribe<'a>)
Tuple Fields of Subscribe
0: Subscribe<'a>
Suback(Suback<'a>)
Tuple Fields of Suback
0: Suback<'a>
Unsubscribe(Unsubscribe<'a>)
Tuple Fields of Unsubscribe
0: Unsubscribe<'a>
Unsuback(Pid)
Tuple Fields of Unsuback
0: Pid
Implementations
Trait Implementations
Performs the conversion.