pub enum MqttError {
Show 57 variants
Io(String),
InvalidTopicName(String),
InvalidTopicFilter(String),
InvalidClientId(String),
ConnectionError(String),
ConnectionRefused(ReasonCode),
ProtocolError(String),
MalformedPacket(String),
PacketTooLarge {
size: usize,
max: usize,
},
AuthenticationFailed,
NotAuthorized,
NotConnected,
AlreadyConnected,
Timeout,
SubscriptionFailed(ReasonCode),
UnsubscriptionFailed(ReasonCode),
PublishFailed(ReasonCode),
PacketIdNotFound(u16),
PacketIdInUse(u16),
InvalidQoS(u8),
InvalidPacketType(u8),
InvalidReasonCode(u8),
InvalidPropertyId(u8),
DuplicatePropertyId(u8),
SessionExpired,
KeepAliveTimeout,
ServerShuttingDown,
ClientClosed,
ConnectionClosedByPeer,
MaxConnectTime,
TopicAliasInvalid(u16),
ReceiveMaximumExceeded,
WillRejected,
ImplementationSpecific(String),
UnsupportedProtocolVersion,
InvalidState(String),
ClientIdentifierNotValid,
BadUsernameOrPassword,
ServerUnavailable,
ServerBusy,
Banned,
BadAuthenticationMethod,
QuotaExceeded,
PayloadFormatInvalid,
RetainNotSupported,
QoSNotSupported,
UseAnotherServer,
ServerMoved,
SharedSubscriptionsNotSupported,
ConnectionRateExceeded,
SubscriptionIdentifiersNotSupported,
WildcardSubscriptionsNotSupported,
MessageTooLarge,
FlowControlExceeded,
PacketIdExhausted,
StringTooLong(usize),
Configuration(String),
}Expand description
MQTT protocol errors
This enum provides specific error variants for all possible MQTT protocol errors, validation failures, and operational issues.
§Error Categories
- I/O and Network:
Io,ConnectionError,Timeout,NotConnected - Validation:
InvalidTopicName,InvalidTopicFilter,InvalidClientId - Protocol:
ProtocolError,MalformedPacket,InvalidPacketType - Authentication:
AuthenticationFailed,NotAuthorized,BadUsernameOrPassword - Operations:
SubscriptionFailed,PublishFailed,UnsubscriptionFailed - Server Status:
ServerUnavailable,ServerBusy,ServerShuttingDown - Flow Control:
ReceiveMaximumExceeded,FlowControlExceeded,PacketIdExhausted
§Examples
use mqtt5_protocol::{MqttError, Result};
fn validate_topic(topic: &str) -> Result<()> {
if topic.contains('#') && !topic.ends_with('#') {
return Err(MqttError::InvalidTopicName(
"# wildcard must be at the end".to_string()
));
}
Ok(())
}Variants§
Io(String)
InvalidTopicName(String)
InvalidTopicFilter(String)
InvalidClientId(String)
ConnectionError(String)
ConnectionRefused(ReasonCode)
ProtocolError(String)
MalformedPacket(String)
PacketTooLarge
AuthenticationFailed
NotAuthorized
NotConnected
AlreadyConnected
Timeout
SubscriptionFailed(ReasonCode)
UnsubscriptionFailed(ReasonCode)
PublishFailed(ReasonCode)
PacketIdNotFound(u16)
PacketIdInUse(u16)
InvalidQoS(u8)
InvalidPacketType(u8)
InvalidReasonCode(u8)
InvalidPropertyId(u8)
DuplicatePropertyId(u8)
SessionExpired
KeepAliveTimeout
ServerShuttingDown
ClientClosed
ConnectionClosedByPeer
MaxConnectTime
TopicAliasInvalid(u16)
ReceiveMaximumExceeded
WillRejected
ImplementationSpecific(String)
UnsupportedProtocolVersion
InvalidState(String)
ClientIdentifierNotValid
BadUsernameOrPassword
ServerBusy
Banned
BadAuthenticationMethod
QuotaExceeded
PayloadFormatInvalid
RetainNotSupported
QoSNotSupported
UseAnotherServer
ServerMoved
ConnectionRateExceeded
SubscriptionIdentifiersNotSupported
WildcardSubscriptionsNotSupported
MessageTooLarge
FlowControlExceeded
PacketIdExhausted
StringTooLong(usize)
Configuration(String)
Implementations§
Trait Implementations§
Source§impl Error for MqttError
impl Error for MqttError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for MqttError
impl RefUnwindSafe for MqttError
impl Send for MqttError
impl Sync for MqttError
impl Unpin for MqttError
impl UnwindSafe for MqttError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more