1use std::fmt;
2
3#[derive(Clone, Debug, PartialEq, Eq)]
5#[non_exhaustive]
6pub enum Error {
7 Again,
9
10 Msg(String),
12
13 ParseIpAddr(String),
15}
16
17impl fmt::Display for Error {
18 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19 match self {
20 Self::Msg(s) => write!(f, "{}", s),
21 Self::ParseIpAddr(s) => write!(f, "parsing of ip addr failed, reason: {}", s),
22 Self::Again => write!(f, "try again"),
23 }
24 }
25}
26
27impl std::error::Error for Error {}
28
29pub type Result<T> = core::result::Result<T, Error>;
31
32macro_rules! e_fmt {
34 ($($arg:tt)+) => {
35 Error::Msg(format!($($arg)+))
36 };
37 }
38
39pub(crate) use e_fmt;