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
use std::fmt;
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum Error {
EmptyRoomVersionId,
InvalidCharacters,
InvalidKeyAlgorithm,
InvalidKeyVersion,
InvalidMxcUri,
InvalidServerName,
MaximumLengthExceeded,
MissingDelimiter,
MissingLeadingSigil,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let message = match self {
Error::EmptyRoomVersionId => "room version ID is empty",
Error::InvalidCharacters => "localpart contains invalid characters",
Error::InvalidKeyAlgorithm => "invalid key algorithm specified",
Error::InvalidKeyVersion => "key ID version contains invalid characters",
Error::InvalidMxcUri => "the mxc:// isn't a valid Matrix Content URI",
Error::InvalidServerName => "server name is not a valid IP address or domain name",
Error::MaximumLengthExceeded => "ID exceeds 255 bytes",
Error::MissingDelimiter => "required colon is missing",
Error::MissingLeadingSigil => "leading sigil is incorrect or missing",
};
write!(f, "{}", message)
}
}
impl std::error::Error for Error {}