1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use crate::client::{Command, Request};
use crossbeam_channel::RecvError;
use derive_more::From;
use failure::Fail;
use futures::sync::mpsc::SendError;
#[cfg(feature = "jwt")]
use jsonwebtoken;
use mqtt311::Packet;
use std::io::Error as IoError;
use tokio_timer::{self, timeout};
#[derive(Debug, Fail, From)]
pub enum ClientError {
#[fail(display = "No subscriptions")]
ZeroSubscriptions,
#[fail(display = "Packet size limit has crossed maximum")]
PacketSizeLimitExceeded,
#[fail(display = "Client id should not be empty")]
EmptyClientId,
#[fail(display = "Failed sending request to connection thread. Error = {}", _0)]
MpscRequestSend(SendError<Request>),
#[fail(display = "Failed sending request to connection thread. Error = {}", _0)]
MpscCommandSend(SendError<Command>),
}
#[derive(Debug, Fail, From)]
pub enum MqttError {
#[fail(display = "Connection failed")]
ConnectError,
#[fail(display = "Network call failed")]
NetworkError,
}
#[derive(Debug, Fail, From)]
pub enum ConnectError {
#[fail(display = "Mqtt connection failed. Error = {}", _0)]
MqttConnectionRefused(u8),
#[cfg(feature = "jwt")]
#[fail(display = "Mqtt connection failed. Error = {}", _0)]
Jwt(jsonwebtoken::errors::Error),
#[fail(display = "Io failed. Error = {}", _0)]
Io(IoError),
#[fail(display = "Receiving connection status failed. Error = {}", _0)]
Recv(RecvError),
#[fail(display = "Empty dns list")]
DnsListEmpty,
#[fail(display = "Couldn't create mqtt connection in time")]
Timeout,
#[fail(
display = "Unsolicited packet received while waiting for connack. Recived packet = {:?}",
_0
)]
NotConnackPacket(Packet),
#[fail(display = "Empty response")]
NoResponse,
#[fail(display = "Builder doesn't contain certificate authority")]
NoCertificateAuthority,
}
#[derive(Debug, Fail, From)]
pub enum NetworkError {
#[fail(display = "Io failed. Error = {}", _0)]
Io(IoError),
#[fail(display = "Last ping response not received")]
AwaitPingResp,
#[fail(display = "Client not in connected state")]
InvalidState,
#[fail(display = "Couldn't ping in time")]
Timeout,
#[fail(display = "Received unsolicited acknowledgment")]
Unsolicited,
#[fail(display = "Tokio timer error = {}", _0)]
Timer(tokio_timer::Error),
#[fail(display = "Tokio timer error = {}", _0)]
TimeOut(timeout::Error<IoError>),
#[fail(display = "User requested for reconnect")]
UserReconnect,
#[fail(display = "User requested for disconnect")]
UserDisconnect,
#[fail(display = "Network stream closed")]
NetworkStreamClosed,
#[fail(display = "Throttle error while rate limiting")]
Throttle,
#[fail(display = "Dummy error for converting () to network error")]
Blah,
}