Skip to main content

MqttError

Enum MqttError 

Source
pub enum MqttError<'e> {
Show 15 variants Network(ErrorKind), Server, Alloc, AuthPacketReceived, Disconnect { reason: ReasonCode, reason_string: Option<MqttString<'e>>, server_reference: Option<MqttString<'e>>, }, RecoveryRequired, PacketIdentifierNotInFlight, RepublishQoSNotMatching, PacketIdentifierAwaitingPubcomp, PacketMaximumLengthExceeded, ServerMaximumPacketSizeExceeded, InvalidTopicAlias, SessionBuffer, SendQuotaExceeded, IllegalDisconnectSessionExpiryInterval,
}
Expand description

The main error returned by crate::client::Client.

Distincts between unrecoverable and recoverable errors. Recoverability in this context refers to whether the current network connection can be used for further communication after the error has occured.

§Recovery

  • For unrecoverable errors, crate::client::Client::abort can be called to send an optional DISCONNECT packet if allowed by specification. You can then try to recover the session by calling crate::client::Client::connect again without clean start.
  • For recoverable errors, follow the error-specific behaviour.

Variants§

§

Network(ErrorKind)

An underlying Read/Write method returned an error.

Unrecoverable error. crate::client::Client::abort should be called.

§

Server

The remote server did something the client does not understand / does not match the specification.

Unrecoverable error. crate::client::Client::abort should be called.

§

Alloc

A buffer provision by the crate::buffer::BufferProvider failed. Therefore a packet could not be received correctly.

Unrecoverable error. crate::client::Client::abort should be called.

§

AuthPacketReceived

An AUTH packet header has been received by the client. AUTH packets are not supported by the client. The client has scheduled a DISCONNECT packet with ReasonCode::ImplementationSpecificError. The packet body has not been decoded.

Unrecoverable error. crate::client::Client::abort should be called.

§

Disconnect

The client could not connect to the broker or the broker has sent a DISCONNECT packet.

Unrecoverable error. crate::client::Client::abort should be called.

Fields

§reason: ReasonCode

The ReasonCode of the causing CONNACK or DISCONNECT packet. If the disconnection is caused by a CONNACK packet, the reason code ss always erroneous.

§reason_string: Option<MqttString<'e>>

The reason string property of the causing CONNACK or DISCONNECT packet if the server included a reason string.

§server_reference: Option<MqttString<'e>>

The server reference property of the causing CONNACK or DISCONNCET packet if the server included a server reference. Identifies another server which can be used.

§

RecoveryRequired

Another unrecoverable error has been returned earlier. The underlying connection is in a state, in which it refuses/is not able to perform regular communication.

Unrecoverable error. crate::client::Client::abort should be called.

§

PacketIdentifierNotInFlight

A republish of a packet without an in flight entry was attempted.

Recoverable error. No action has been taken by the client.

§

RepublishQoSNotMatching

A republish of a packet with a quality of service that does not match the quality of service of the original publication was attempted.

Recoverable error. No action has been taken by the client.

§

PacketIdentifierAwaitingPubcomp

A republish of a packet whose corresponding PUBREL packet has already been sent was attempted. Sending the PUBLISH packet in this case would result in a protocol violation.

Recoverable error. No action has been taken by the client.

§

PacketMaximumLengthExceeded

A packet was too long to encode its length with the variable byte integer.

This can currently only be returned from crate::client::Client::publish or crate::client::Client::republish.

Recoverable error. No action has been taken by the client.

§

ServerMaximumPacketSizeExceeded

A packet is too long and would exceed the servers maximum packet size.

Recoverable error. No action has been taken by the client.

§

InvalidTopicAlias

The value of a topic alias in an outgoing PUBLISH packet was 0 or greater than the server’s maximum allowed value. Sending this PUBLISH packet would raise a protocol error.

Recoverable error. No action has been taken by the client.

§

SessionBuffer

An action was rejected because an internal buffer used for tracking session state is full.

Recoverable error. Try again after a crate::client::event::Event has been emitted that indicates that buffer might be free again.

Example: crate::client::Client::subscribe returns this error. Wait until a crate::client::event::Event::Suback is received. This clears a spot in the subscribe packet identifiers.

§

SendQuotaExceeded

A publish now would exceed the server’s receive maximum and ultimately cause a protocol error.

Recoverable error. Try again after either crate::client::event::Event::PublishAcknowledged or crate::client::event::Event::PublishComplete has been emitted that indicates that buffer might be free again. been emitted that indicates that buffer might be free again.

§

IllegalDisconnectSessionExpiryInterval

A disconnect now with the given session expiry interval would cause a protocol error.

A disconnection was attempted with a session expiry interval change where the session expiry interval in the CONNECT packet was zero (crate::config::SessionExpiryInterval::EndOnDisconnect) and was greater than zero (crate::config::SessionExpiryInterval::NeverEnd or crate::config::SessionExpiryInterval::Seconds) in the DISCONNECT packet.

Recoverable error. Try disconnecting again without an session expiry interval or with a session expiry interval of zero (crate::config::SessionExpiryInterval::EndOnDisconnect).

Implementations§

Source§

impl Error<'_>

Source

pub fn is_recoverable(&self) -> bool

Returns whether the client can recover from this error without closing the network connection.

Trait Implementations§

Source§

impl<'e> Clone for Error<'e>

Source§

fn clone(&self) -> Error<'e>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'e> Debug for Error<'e>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Reserved> for Error<'_>

Source§

fn from(_: Reserved) -> Self

Converts to this type from the input type.
Source§

impl From<TooLargeToEncode> for Error<'_>

Source§

fn from(_: TooLargeToEncode) -> Self

Converts to this type from the input type.
Source§

impl<'e> PartialEq for Error<'e>

Source§

fn eq(&self, other: &Error<'e>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'e> Eq for Error<'e>

Source§

impl<'e> StructuralPartialEq for Error<'e>

Auto Trait Implementations§

§

impl<'e> Freeze for Error<'e>

§

impl<'e> RefUnwindSafe for Error<'e>

§

impl<'e> Send for Error<'e>

§

impl<'e> Sync for Error<'e>

§

impl<'e> Unpin for Error<'e>

§

impl<'e> UnsafeUnpin for Error<'e>

§

impl<'e> UnwindSafe for Error<'e>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.