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
89
90
91
92
use native_tls::Error as NativeTlsError;
use std::io::Error as IoError;
use thiserror::Error;
use url::ParseError;
#[derive(Error, Debug)]
pub enum WebSocketError {
#[error("could not connect using TCP")]
TcpConnectionError(IoError),
#[error("could not connect using TLS")]
TlsConnectionError(NativeTlsError),
#[error("could not build WebSocket with given TLS configuration")]
TlsBuilderError(NativeTlsError),
#[error("error with TLS configuration")]
TlsConfigurationError(NativeTlsError),
#[error("websocket is already closed")]
WebSocketClosedError,
#[error("error shutting down stream")]
ShutdownError(IoError),
#[error("invalid handshake response")]
InvalidHandshakeError,
#[error("server rejected handshake")]
HandshakeFailedError {
status_code: String,
headers: Vec<(String, String)>,
body: Option<String>,
},
#[error("control frame has payload larger than 125 bytes")]
ControlFrameTooLargeError,
#[error("payload is too large")]
PayloadTooLargeError,
#[error("received frame is invalid")]
InvalidFrameError,
#[error("received masked frame")]
ReceivedMaskedFrameError,
#[error("url could not be parsed")]
ParseError(ParseError),
#[error(r#"invalid websocket scheme (use "ws" or "wss")"#)]
SchemeError,
#[error("invalid or missing host")]
HostError,
#[error("invalid or unknown port")]
PortError,
#[error("could not parse into SocketAddrs")]
SocketAddrError(IoError),
#[error("could not resolve domain")]
ResolutionError,
#[error("could not read from WebSocket")]
ReadError(IoError),
#[error("could not write to WebSocket")]
WriteError(IoError),
#[error("error using channel")]
ChannelError,
}