pub enum Packet<'a> {
Show 14 variants Connect(Connect<'a>), Connack(Connack), Publish(Publish<'a>), Puback(Pid), Pubrec(Pid), Pubrel(Pid), Pubcomp(Pid), Subscribe(Subscribe<'a>), Suback(Suback<'a>), Unsubscribe(Unsubscribe<'a>), Unsuback(Pid), Pingreq, Pingresp, Disconnect,
}
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>)

Connack(Connack)

Publish(Publish<'a>)

Puback(Pid)

Pubrec(Pid)

Pubrel(Pid)

Pubcomp(Pid)

Subscribe(Subscribe<'a>)

Suback(Suback<'a>)

Unsubscribe(Unsubscribe<'a>)

Unsuback(Pid)

Pingreq

Pingresp

Disconnect

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.