Skip to main content

rust_mqtt/config/
server.rs

1use core::num::NonZero;
2
3use crate::{
4    config::{MaximumPacketSize, ReceiveMaximum},
5    types::QoS,
6};
7
8/// Configuration of the server which must be upheld by the client.
9#[derive(Debug, Clone, Copy)]
10#[cfg_attr(feature = "defmt", derive(defmt::Format))]
11pub struct Config {
12    /// Maximum concurrent [`QoS`] 1 & 2 publications that the server is willing to accept.
13    pub receive_maximum: ReceiveMaximum,
14
15    /// Maximum supported [`QoS`] by the server.
16    pub maximum_qos: QoS,
17
18    /// Retained messages are supported by the server.
19    pub retain_supported: bool,
20
21    /// Maximum packet size that the server is willing to accept.
22    pub maximum_packet_size: MaximumPacketSize,
23
24    /// Highest value of a topic alias the server is willing to accept.
25    /// Equal to the number of distinct topic aliases the server supports.
26    pub topic_alias_maximum: u16,
27
28    /// Serverside support for wildcard subscriptions.
29    pub wildcard_subscription_supported: bool,
30    /// Serverside support for subscription identifiers.
31    pub subscription_identifiers_supported: bool,
32    /// Serverside support for shared subscriptions.
33    pub shared_subscription_supported: bool,
34}
35
36impl Default for Config {
37    fn default() -> Self {
38        Self {
39            receive_maximum: ReceiveMaximum(NonZero::new(u16::MAX).unwrap()),
40            maximum_qos: QoS::ExactlyOnce,
41            retain_supported: true,
42            maximum_packet_size: MaximumPacketSize::default(),
43            topic_alias_maximum: 0,
44            wildcard_subscription_supported: true,
45            subscription_identifiers_supported: true,
46            shared_subscription_supported: true,
47        }
48    }
49}