use heapless::Vec;
use crate::{
bytes::Bytes,
types::{
IdentifiedQoS, MqttBinary, MqttString, PacketIdentifier, ReasonCode, TopicName, VarByteInt,
},
};
#[allow(unused_imports)]
use crate::types::QoS;
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Event<'e, const MAX_SUBSCRIPTION_IDENTIFIERS: usize> {
Pingresp,
Publish(Publish<'e, MAX_SUBSCRIPTION_IDENTIFIERS>),
Suback(Suback),
Unsuback(Suback),
PublishRejected(Pubrej),
PublishAcknowledged(Puback),
PublishReceived(Puback),
PublishReleased(Puback),
PublishComplete(Puback),
Ignored,
Duplicate,
}
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Suback {
pub packet_identifier: PacketIdentifier,
pub reason_code: ReasonCode,
}
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Publish<'p, const MAX_SUBSCRIPTION_IDENTIFIERS: usize> {
pub dup: bool,
pub identified_qos: IdentifiedQoS,
pub retain: bool,
pub topic: TopicName<'p>,
pub payload_format_indicator: Option<bool>,
pub message_expiry_interval: Option<u32>,
pub response_topic: Option<TopicName<'p>>,
pub correlation_data: Option<MqttBinary<'p>>,
pub subscription_identifiers: Vec<VarByteInt, MAX_SUBSCRIPTION_IDENTIFIERS>,
pub content_type: Option<MqttString<'p>>,
pub message: Bytes<'p>,
}
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Puback {
pub packet_identifier: PacketIdentifier,
pub reason_code: ReasonCode,
}
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Pubrej {
pub packet_identifier: PacketIdentifier,
pub reason_code: ReasonCode,
}