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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
use thiserror::Error;
use std::io;
use std::net;
use std::num::ParseIntError;
use std::time::SystemTimeError;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error, PartialEq)]
#[non_exhaustive]
pub enum Error {
#[error("Unknown type")]
ErrUnknownType,
#[error("unknown scheme type")]
ErrSchemeType,
#[error("queries not supported in stun address")]
ErrStunQuery,
#[error("invalid query")]
ErrInvalidQuery,
#[error("invalid hostname")]
ErrHost,
#[error("invalid port number")]
ErrPort,
#[error("local username fragment is less than 24 bits long")]
ErrLocalUfragInsufficientBits,
#[error("local password is less than 128 bits long")]
ErrLocalPwdInsufficientBits,
#[error("invalid transport protocol type")]
ErrProtoType,
#[error("the agent is closed")]
ErrClosed,
#[error("no candidate pairs available")]
ErrNoCandidatePairs,
#[error("connecting canceled by caller")]
ErrCanceledByCaller,
#[error("attempted to start agent twice")]
ErrMultipleStart,
#[error("remote ufrag is empty")]
ErrRemoteUfragEmpty,
#[error("remote pwd is empty")]
ErrRemotePwdEmpty,
#[error("no on_candidate provided")]
ErrNoOnCandidateHandler,
#[error("attempting to gather candidates during gathering state")]
ErrMultipleGatherAttempted,
#[error("username is empty")]
ErrUsernameEmpty,
#[error("password is empty")]
ErrPasswordEmpty,
#[error("failed to parse address")]
ErrAddressParseFailed,
#[error("lite agents must only use host candidates")]
ErrLiteUsingNonHostCandidates,
#[error("agent does not need URL with selected candidate types")]
ErrUselessUrlsProvided,
#[error("unsupported 1:1 NAT IP candidate type")]
ErrUnsupportedNat1to1IpCandidateType,
#[error("invalid 1:1 NAT IP mapping")]
ErrInvalidNat1to1IpMapping,
#[error("external mapped IP not found")]
ErrExternalMappedIpNotFound,
#[error("mDNS gathering cannot be used with 1:1 NAT IP mapping for host candidate")]
ErrMulticastDnsWithNat1to1IpMapping,
#[error("1:1 NAT IP mapping for host candidate ineffective")]
ErrIneffectiveNat1to1IpMappingHost,
#[error("1:1 NAT IP mapping for srflx candidate ineffective")]
ErrIneffectiveNat1to1IpMappingSrflx,
#[error("invalid mDNS HostName, must end with .local and can only contain a single '.'")]
ErrInvalidMulticastDnshostName,
#[error("ICE Agent can not be restarted when gathering")]
ErrRestartWhenGathering,
#[error("run was canceled by done")]
ErrRunCanceled,
#[error("TCPMux is not initialized")]
ErrTcpMuxNotInitialized,
#[error("conn with same remote addr already exists")]
ErrTcpRemoteAddrAlreadyExists,
#[error("failed to send packet")]
ErrSendPacket,
#[error("attribute not long enough to be ICE candidate")]
ErrAttributeTooShortIceCandidate,
#[error("could not parse component")]
ErrParseComponent,
#[error("could not parse priority")]
ErrParsePriority,
#[error("could not parse port")]
ErrParsePort,
#[error("could not parse related addresses")]
ErrParseRelatedAddr,
#[error("could not parse type")]
ErrParseType,
#[error("unknown candidate type")]
ErrUnknownCandidateType,
#[error("failed to get XOR-MAPPED-ADDRESS response")]
ErrGetXorMappedAddrResponse,
#[error("connection with same remote address already exists")]
ErrConnectionAddrAlreadyExist,
#[error("error reading streaming packet")]
ErrReadingStreamingPacket,
#[error("error writing to")]
ErrWriting,
#[error("error closing connection")]
ErrClosingConnection,
#[error("unable to determine networkType")]
ErrDetermineNetworkType,
#[error("missing protocol scheme")]
ErrMissingProtocolScheme,
#[error("too many colons in address")]
ErrTooManyColonsAddr,
#[error("unexpected error trying to read")]
ErrRead,
#[error("unknown role")]
ErrUnknownRole,
#[error("username mismatch")]
ErrMismatchUsername,
#[error("the ICE conn can't write STUN messages")]
ErrIceWriteStunMessage,
#[error("invalid url")]
ErrInvalidUrl,
#[error("relative URL without a base")]
ErrUrlParse,
#[error("Candidate IP could not be found")]
ErrCandidateIpNotFound,
#[error("parse int: {0}")]
ParseInt(#[from] ParseIntError),
#[error("parse addr: {0}")]
ParseIp(#[from] net::AddrParseError),
#[error("{0}")]
Io(#[source] IoError),
#[error("{0}")]
Util(#[from] util::Error),
#[error("{0}")]
Stun(#[from] stun::Error),
#[error("{0}")]
ParseUrl(#[from] url::ParseError),
#[error("{0}")]
Mdns(#[from] mdns::Error),
#[error("{0}")]
Turn(#[from] turn::Error),
#[error("{0}")]
Other(String),
}
#[derive(Debug, Error)]
#[error("io error: {0}")]
pub struct IoError(#[from] pub io::Error);
impl PartialEq for IoError {
fn eq(&self, other: &Self) -> bool {
self.0.kind() == other.0.kind()
}
}
impl From<io::Error> for Error {
fn from(e: io::Error) -> Self {
Error::Io(IoError(e))
}
}
impl From<SystemTimeError> for Error {
fn from(e: SystemTimeError) -> Self {
Error::Other(e.to_string())
}
}