mqtt_tiny/
_defaults.rs

1// Provides some type aliases that offer reasonable defaults for the underlying container types
2
3/// Validates the feature combination
4const _FEATURES_VALID: bool = match (cfg!(feature = "std"), cfg!(feature = "arrayvec"), cfg!(feature = "heapless")) {
5    (true, false, false) | (false, true, false) | (false, false, true) => true,
6    _ => panic!("you must not select more than one backing at a time (i.e. `std` or `arrayvec` or `heapless`)"),
7};
8
9/// The default byte container type used within top-level types
10#[cfg(feature = "std")]
11#[doc(hidden)]
12pub type Bytes = std::vec::Vec<u8>;
13/// The default byte container type used within top-level types
14///
15/// # Note
16/// This default configuration allows for 256 bytes per byte field on the stack.
17#[cfg(feature = "arrayvec")]
18#[doc(hidden)]
19pub type Bytes = arrayvec::ArrayVec<u8, 256>;
20/// The default byte container type used within top-level types
21///
22/// # Note
23/// This default configuration allows for 256 bytes per byte field on the stack.
24#[cfg(feature = "heapless")]
25#[doc(hidden)]
26pub type Bytes = heapless::Vec<u8, 256>;
27
28/// The default collection type for topic lists used within top-level types
29#[cfg(feature = "std")]
30#[doc(hidden)]
31pub type Topics = std::vec::Vec<Bytes>;
32/// The default collection type for topic lists used within top-level types
33///
34/// # Note
35/// This default configuration allows for 4 topics per unsubscribe message.
36#[cfg(feature = "arrayvec")]
37#[doc(hidden)]
38pub type Topics = arrayvec::ArrayVec<Bytes, 4>;
39/// The default collection type for topic lists used within top-level types
40///
41/// # Note
42/// This default configuration allows for 4 topics per unsubscribe message.
43#[cfg(feature = "heapless")]
44#[doc(hidden)]
45pub type Topics = heapless::Vec<Bytes, 4>;
46
47/// The default collection type for topic+quality-of-service lists used within top-level types
48#[cfg(feature = "std")]
49#[doc(hidden)]
50pub type TopicsQos = std::vec::Vec<(Bytes, u8)>;
51/// The default collection type for topic+quality-of-service lists used within top-level types
52///
53/// # Note
54/// This default configuration allows for 4 topic+quality-of-service tuples per subscribe message.
55#[cfg(feature = "arrayvec")]
56#[doc(hidden)]
57pub type TopicsQos = arrayvec::ArrayVec<(Bytes, u8), 4>;
58/// The default collection type for topic+quality-of-service lists used within top-level types
59///
60/// # Note
61/// This default configuration allows for 4 topic+quality-of-service tuples per subscribe message.
62#[cfg(feature = "heapless")]
63#[doc(hidden)]
64pub type TopicsQos = heapless::Vec<(Bytes, u8), 4>;
65
66/// A type-erased MQTT packet
67pub type Packet = crate::packets::packet::Packet<Topics, TopicsQos, Bytes>;
68/// An MQTT [`CONNACK` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718033)
69pub type Connack = crate::packets::connack::Connack;
70/// An MQTT [`CONNECT` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718033)
71pub type Connect = crate::packets::connect::Connect<Bytes>;
72/// An MQTT [`DISCONNECT` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718090)
73pub type Disconnect = crate::packets::disconnect::Disconnect;
74/// An MQTT [`PINGREQ` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718081)
75pub type Pingreq = crate::packets::pingreq::Pingreq;
76/// An MQTT [`PINGRESP` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718086)
77pub type Pingresp = crate::packets::pingresp::Pingresp;
78/// An MQTT [`PUBACK` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718043)
79pub type Puback = crate::packets::puback::Puback;
80/// An MQTT [`PUBCOMP` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718058)
81pub type Pubcomp = crate::packets::pubcomp::Pubcomp;
82/// An MQTT [`PUBLISH` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718037)
83pub type Publish = crate::packets::publish::Publish<Bytes>;
84/// An MQTT [`PUBREC` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718048)
85pub type Pubrec = crate::packets::pubrec::Pubrec;
86/// An MQTT [`PUBREL` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718053)
87pub type Pubrel = crate::packets::pubrel::Pubrel;
88/// An MQTT [`SUBACK` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718068)
89pub type Suback = crate::packets::suback::Suback;
90/// An MQTT [`SUBSCRIBE` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718063)
91pub type Subscribe = crate::packets::subscribe::Subscribe<TopicsQos, Bytes>;
92/// An MQTT [`UNSUBACK` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718077)
93pub type Unsuback = crate::packets::unsuback::Unsuback;
94/// An MQTT [`UNSUBSCRIBE` packet](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718072)
95pub type Unsubscribe = crate::packets::unsubscribe::Unsubscribe<Topics, Bytes>;