validators/errors/
host.rs1use core::fmt::{self, Display, Formatter};
2#[cfg(feature = "std")]
3use std::error::Error;
4
5#[derive(Debug, Clone)]
7pub enum HostError {
8 Invalid,
10 LocalMust,
12 LocalDisallow,
14 AtLeastTwoLabelsMust,
16 AtLeastTwoLabelsDisallow,
18 PortMust,
20 PortDisallow,
22}
23
24impl Display for HostError {
25 #[inline]
26 fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
27 match self {
28 Self::Invalid => f.write_str("invalid domain or IP"),
29 Self::LocalMust => f.write_str("must be local"),
30 Self::LocalDisallow => f.write_str("must not be local"),
31 Self::AtLeastTwoLabelsMust => f.write_str("must have at least two labels"),
32 Self::AtLeastTwoLabelsDisallow => f.write_str("must have only one label"),
33 Self::PortMust => f.write_str("port not found"),
34 Self::PortDisallow => f.write_str("port not allowed"),
35 }
36 }
37}
38
39#[cfg(feature = "std")]
40impl Error for HostError {}