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
use core::fmt::{self, Display, Formatter};
#[cfg(feature = "std")]
use std::error::Error;
#[derive(Debug, Clone)]
pub enum DomainError {
Invalid,
IPv4Must,
IPv4NotAllow,
LocalMust,
LocalNotAllow,
AtLeastTwoLabelsMust,
AtLeastTwoLabelsNotAllow,
PortMust,
PortNotAllow,
}
impl Display for DomainError {
#[inline]
fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
match self {
DomainError::Invalid => f.write_str("invalid domain"),
DomainError::IPv4Must => f.write_str("must use an IPv4"),
DomainError::IPv4NotAllow => f.write_str("must not use an IPv4"),
DomainError::LocalMust => f.write_str("must be local"),
DomainError::LocalNotAllow => f.write_str("must not be local"),
DomainError::AtLeastTwoLabelsMust => f.write_str("must have at least two labels"),
DomainError::AtLeastTwoLabelsNotAllow => f.write_str("must have only one label"),
DomainError::PortMust => f.write_str("port not found"),
DomainError::PortNotAllow => f.write_str("port not allowed"),
}
}
}
#[cfg(feature = "std")]
impl Error for DomainError {}