Struct MqttClientBuilder
pub struct MqttClientBuilder<'a> {
pub(crate) certificate: Option<&'a [u8]>,
pub(crate) private_key: Option<&'a [u8]>,
pub(crate) certificate_authority: Option<&'a [u8]>,
pub(crate) thing_name: Option<&'a str>,
pub(crate) endpoint: Option<Cow<'a, str>>,
pub(crate) keep_alive: Option<Duration>,
pub(crate) min_reconnect_delay: Option<Duration>,
pub(crate) max_reconnect_delay: Option<Duration>,
pub(crate) connect_timeout: Option<Duration>,
pub(crate) subscriber_capacity: usize,
pub(crate) port: Option<u16>,
}Expand description
A builder for creating an MqttClient with specific configurations.
Fields§
§certificate: Option<&'a [u8]>§private_key: Option<&'a [u8]>§thing_name: Option<&'a str>§endpoint: Option<Cow<'a, str>>§keep_alive: Option<Duration>§min_reconnect_delay: Option<Duration>§max_reconnect_delay: Option<Duration>§connect_timeout: Option<Duration>§subscriber_capacity: usize§port: Option<u16>Implementations§
§impl<'a> MqttClientBuilder<'a>
impl<'a> MqttClientBuilder<'a>
pub const fn new() -> Self
pub const fn new() -> Self
pub const fn thing_name(self, name: &'a str) -> Self
pub const fn thing_name(self, name: &'a str) -> Self
Sets the name of the thing
pub fn endpoint(self, endpoint: &'a str) -> Self
pub fn endpoint(self, endpoint: &'a str) -> Self
Sets the MQTT endpoint to connect to.
See also endpoint_owned.
pub fn endpoint_owned(self, endpoint: String) -> Self
pub fn endpoint_owned(self, endpoint: String) -> Self
Sets the MQTT endpoint to connect to.
pub const fn certificate(self, cert: &'a [u8]) -> Self
pub const fn certificate(self, cert: &'a [u8]) -> Self
Sets the certificate to use for the MQTT connection.
pub const fn private_key(self, key: &'a [u8]) -> Self
pub const fn private_key(self, key: &'a [u8]) -> Self
Sets the private key to use for the MQTT connection.
pub const fn ca(self, ca: &'a [u8]) -> Self
pub const fn ca(self, ca: &'a [u8]) -> Self
Sets the certificate authority to use for the MQTT connection.
pub const fn keep_alive(self, time: Duration) -> Self
pub const fn keep_alive(self, time: Duration) -> Self
Set number of seconds after which client should ping the broker if there is no other data exchange
pub const fn connect_timeout(self, time: Duration) -> Self
pub const fn connect_timeout(self, time: Duration) -> Self
Sets the connect timeout.
This timeout is used when connecting to the broker. The value only has a resolution of seconds.
Any value less than 1 second will be treated as 0 seconds, which will cause the connection to fail instantly.
Defaults to 5 seconds.
pub const fn min_reconnect_delay(self, time: Duration) -> Self
pub const fn min_reconnect_delay(self, time: Duration) -> Self
Sets the minimum delay between reconnection attempts.
If set to Duration::ZERO, the client will always attempt to reconnect
immediately without delay, effectively disabling backoff.
This is not recommended for production use.
Defaults to 1 second.
pub const fn max_reconnect_delay(self, time: Duration) -> Self
pub const fn max_reconnect_delay(self, time: Duration) -> Self
Sets the maximum delay between reconnection attempts.
If set to a value less than the minimum reconnect delay, the minimum reconnect delay will be used instead.
Defaults to 5 minutes.
pub const fn subscriber_capacity(self, size: usize) -> Self
pub const fn subscriber_capacity(self, size: usize) -> Self
Sets the maximum capacity for a Subscriber receiver channel.
This allows controlling the buffer size for incoming messages to
subscribers. A larger buffer can prevent message loss, but may
consume more memory.