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
use std::string::FromUtf8Error;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error, PartialEq)]
#[non_exhaustive]
pub enum Error {
#[error(
"DataChannel message is not long enough to determine type: (expected: {expected}, actual: {actual})"
)]
UnexpectedEndOfBuffer { expected: usize, actual: usize },
#[error("Unknown MessageType {0}")]
InvalidMessageType(u8),
#[error("Unknown ChannelType {0}")]
InvalidChannelType(u8),
#[error("Unknown PayloadProtocolIdentifier {0}")]
InvalidPayloadProtocolIdentifier(u8),
#[error("Stream closed")]
ErrStreamClosed,
#[error("{0}")]
Util(#[from] util::Error),
#[error("{0}")]
Sctp(#[from] sctp::Error),
#[error("utf-8 error: {0}")]
Utf8(#[from] FromUtf8Error),
#[allow(non_camel_case_types)]
#[error("{0}")]
new(String),
}
impl From<Error> for util::Error {
fn from(e: Error) -> Self {
util::Error::from_std(e)
}
}
impl PartialEq<util::Error> for Error {
fn eq(&self, other: &util::Error) -> bool {
if let Some(down) = other.downcast_ref::<Error>() {
return self == down;
}
false
}
}
impl PartialEq<sctp::Error> for Error {
fn eq(&self, other: &sctp::Error) -> bool {
if let Error::Sctp(e) = self {
return e == other;
}
false
}
}