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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
use thiserror::Error;
use std::io;
#[derive(Debug, Error)]
#[error(transparent)]
pub struct ParseError(#[from] pub(crate) ParseErrorInner);
#[derive(Debug, Error)]
pub(crate) enum ParseErrorInner {
#[error("failed to parse socket address")]
ResolvAddr(#[from] crate::resolv_addr::ResolvAddrError),
#[cfg(all(target_os = "linux", feature = "enable_systemd"))]
#[error("invalid character '{c}' in systemd socket name {string} at position {pos}")]
InvalidCharacter { string: String, c: char, pos: usize, },
#[cfg(all(target_os = "linux", feature = "enable_systemd"))]
#[error("systemd socket name {string} is {len} characters long which is more than the limit 255")]
LongSocketName { string: String, len: usize, },
#[cfg(not(all(target_os = "linux", feature = "enable_systemd")))]
#[cfg_attr(not(target_os = "linux"), error("can't parse {0} because systemd is not supported on this operating system"))]
#[cfg_attr(target_os = "linux", error("can't parse {0} because systemd support was disabled during build"))]
SystemdUnsupported(String),
}
#[derive(Debug, Error)]
pub enum ParseOsStrError {
#[error("the address is not a valid UTF-8 string")]
InvalidUtf8,
#[error(transparent)]
InvalidAddress(#[from] ParseError),
}
#[derive(Debug, Error)]
#[error(transparent)]
pub struct BindError(#[from] pub(crate) BindErrorInner);
#[derive(Debug, Error)]
pub(crate) enum BindErrorInner {
#[error("failed to bind {addr}")]
BindFailed { addr: std::net::SocketAddr, #[source] error: io::Error, },
#[error("failed to bind {addr}")]
BindOrResolvFailed { addr: crate::resolv_addr::ResolvAddr, #[source] error: io::Error, },
#[cfg(all(target_os = "linux", feature = "enable_systemd"))]
#[error("failed to receive descriptors with names")]
ReceiveDescriptors(#[source] crate::systemd_sockets::Error),
#[error("missing systemd socket {0} - a typo or an attempt to bind twice")]
#[cfg(all(target_os = "linux", feature = "enable_systemd"))]
MissingDescriptor(String),
#[error("the systemd socket {0} is not an internet socket")]
#[cfg(all(target_os = "linux", feature = "enable_systemd"))]
NotInetSocket(String),
}
#[cfg(any(feature = "tokio_0_2", feature = "tokio_0_3"))]
#[derive(Debug, Error)]
#[error(transparent)]
pub enum TokioBindError {
Bind(#[from] BindError),
Convert(#[from] TokioConversionError),
}
#[cfg(any(feature = "tokio_0_2", feature = "tokio_0_3"))]
#[derive(Debug, Error)]
#[error("failed to convert std socket {addr} into tokio socket")]
pub struct TokioConversionError {
pub(crate) addr: crate::SocketAddrInner,
#[source]
pub(crate) error: io::Error,
}