pub enum MqttError<T> {
Transport(T),
Protocol(ProtocolError),
ConnectionRefused(ConnectReasonCode),
NotConnected,
BufferTooSmall,
Timeout,
}
Expand description
The primary error enum for the MQTT client.
It is generic over the transport error type T
, allowing it to wrap
specific errors from the underlying network transport (e.g., TCP, UART).
Variants§
Transport(T)
An error occurred in the underlying transport layer.
Protocol(ProtocolError)
A protocol-level error occurred, indicating a violation of the MQTT specification.
ConnectionRefused(ConnectReasonCode)
The connection was refused by the broker. The enclosed code provides the reason.
NotConnected
The client is not currently connected to the broker.
BufferTooSmall
The buffer provided for an operation was too small.
Timeout
An operation timed out.
Implementations§
Source§impl<T: TransportError> MqttError<T>
impl<T: TransportError> MqttError<T>
Sourcepub fn cast_transport_error<E: TransportError>(
other: MqttError<E>,
) -> MqttError<T>
pub fn cast_transport_error<E: TransportError>( other: MqttError<E>, ) -> MqttError<T>
A helper method to convert an MqttError
with a placeholder transport error
into an MqttError
with a specific transport error type T
.
This is used to bridge the gap between generic packet encoding functions
and the specific error type required by the client’s Result
.
Trait Implementations§
Source§impl<T: TransportError> From<T> for MqttError<T>
Implements the From
trait to allow for automatic conversion of any transport
error into an MqttError
. This is what allows the ?
operator to work
seamlessly on Result
s from the transport layer.
impl<T: TransportError> From<T> for MqttError<T>
Implements the From
trait to allow for automatic conversion of any transport
error into an MqttError
. This is what allows the ?
operator to work
seamlessly on Result
s from the transport layer.