Skip to main content

mqttbytes_core/
qos.rs

1/// Quality of service
2#[repr(u8)]
3#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Default)]
4#[allow(clippy::enum_variant_names)]
5pub enum QoS {
6    #[default]
7    AtMostOnce = 0,
8    AtLeastOnce = 1,
9    ExactlyOnce = 2,
10}
11
12/// Maps a number to `QoS`
13#[must_use]
14pub const fn qos(num: u8) -> Option<QoS> {
15    match num {
16        0 => Some(QoS::AtMostOnce),
17        1 => Some(QoS::AtLeastOnce),
18        2 => Some(QoS::ExactlyOnce),
19        _ => None,
20    }
21}