#[non_exhaustive]pub enum ConnectionEstablishmentError {
Network(BackendError),
BrokerRejected {
code: ConnectReasonCode,
},
Timeout {
timeout_millis: u64,
},
BrokerDisconnected {
reason_code: Option<DisconnectReasonCode>,
},
}Expand description
Errors that can occur during MQTT connection establishment phase.
These errors represent different failure modes when attempting to establish an initial connection to the MQTT broker. They are distinguished from runtime connection errors that occur after a successful initial connection.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Network(BackendError)
Network-level connection failure (DNS, TCP, TLS, I/O, protocol state)
BrokerRejected
MQTT broker rejected the connection attempt
The network connection was successful, but the MQTT broker refused the connection for protocol-level reasons (authentication, protocol version, etc.)
Fields
code: ConnectReasonCodeThe specific rejection reason code from the broker
Timeout
Connection establishment exceeded the configured timeout
The connection attempt took longer than the specified timeout period. This can happen due to network latency, broker overload, or network instability.
BrokerDisconnected
The broker sent a DISCONNECT during the establishment handshake.
Distinct from BrokerRejected (a failed CONNACK):
here the broker tore the connection down with a v5 DISCONNECT. Only
reachable on MQTT 5, where the reason code is always present (a bare
DISCONNECT decodes as NormalDisconnection).
Fields
reason_code: Option<DisconnectReasonCode>The v5 disconnect reason code.
Trait Implementations§
Source§impl Debug for ConnectionEstablishmentError
impl Debug for ConnectionEstablishmentError
Source§impl Error for ConnectionEstablishmentError
impl Error for ConnectionEstablishmentError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<BackendPollError> for ConnectionEstablishmentError
impl From<BackendPollError> for ConnectionEstablishmentError
Source§fn from(err: BackendPollError) -> ConnectionEstablishmentError
fn from(err: BackendPollError) -> ConnectionEstablishmentError
Classify the poll error, recovering the broker reason code on the
ConnectionRefused path.