actix_mqtt/
error.rs

1use std::io;
2
3/// Errors which can occur when attempting to handle mqtt connection.
4#[derive(Debug)]
5pub enum MqttError<E> {
6    /// Message handler service error
7    Service(E),
8    /// Mqtt parse error
9    Protocol(mqtt_codec::ParseError),
10    /// Unexpected packet
11    Unexpected(mqtt_codec::Packet, &'static str),
12    /// "SUBSCRIBE, UNSUBSCRIBE, and PUBLISH (in cases where QoS > 0) Control Packets MUST contain a non-zero 16-bit Packet Identifier [MQTT-2.3.1-1]."
13    PacketIdRequired,
14    /// Keep alive timeout
15    KeepAliveTimeout,
16    /// Handshake timeout
17    HandshakeTimeout,
18    /// Peer disconnect
19    Disconnected,
20    /// Unexpected io error
21    Io(io::Error),
22}
23
24impl<E> From<mqtt_codec::ParseError> for MqttError<E> {
25    fn from(err: mqtt_codec::ParseError) -> Self {
26        MqttError::Protocol(err)
27    }
28}
29
30impl<E> From<io::Error> for MqttError<E> {
31    fn from(err: io::Error) -> Self {
32        MqttError::Io(err)
33    }
34}