Skip to main content

rust_mqtt/session/
flight.rs

1use crate::types::PacketIdentifier;
2
3#[allow(unused_imports)]
4use crate::types::QoS;
5
6/// An incomplete [`QoS`] 1 or 2 publication.
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9pub struct InFlightPublish<S> {
10    /// The packet identifier of the publication process.
11    pub packet_identifier: PacketIdentifier,
12    /// The state of the publication process.
13    pub state: S,
14}
15
16/// The state of an incomplete [`QoS`] 1 or 2 publication by the client.
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18#[cfg_attr(feature = "defmt", derive(defmt::Format))]
19pub enum CPublishFlightState {
20    /// A [`QoS`] 1 PUBLISH packet has been sent.
21    /// The next step in the handshake is the server sending a PUBACK packet.
22    AwaitingPuback,
23    /// A [`QoS`] 2 PUBLISH packet has been sent.
24    /// The next step in the handshake is the server sending a PUBREC packet.
25    AwaitingPubrec,
26    /// A PUBREC packet has been received and responded to with a PUBREL packet.
27    /// The last step in the handshake is the server sending a PUBCOMP packet.
28    AwaitingPubcomp,
29}
30
31/// The state of an incomplete [`QoS`] 2 publication by the server.
32#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33#[cfg_attr(feature = "defmt", derive(defmt::Format))]
34pub enum SPublishFlightState {
35    /// A [`QoS`] 2 packet has been received and responded to with a PUBREC packet.
36    /// The next step in the handshake is the server sending a PUBREL packet.
37    AwaitingPubrel,
38}