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
use std::net::SocketAddr;
#[cfg(unix)]
use std::path::PathBuf;
#[cfg(test)]
use mock_io::tokio::MockListener;
#[derive(Debug)]
pub enum Address {
Tcp(SocketAddr),
#[cfg(unix)]
#[cfg_attr(feature = "doc", doc(cfg(unix)))]
Uds(PathBuf),
#[cfg(test)]
Mock(MockListener),
}
impl From<SocketAddr> for Address {
fn from(addr: SocketAddr) -> Self {
Self::Tcp(addr)
}
}
#[cfg(unix)]
impl From<PathBuf> for Address {
fn from(path: PathBuf) -> Self {
Self::Uds(path)
}
}
#[cfg(test)]
impl From<MockListener> for Address {
fn from(listener: MockListener) -> Self {
Self::Mock(listener)
}
}