1 | use std::fmt; |
2 | use std::path::Path; |
3 | |
4 | /// An address associated with a Tokio Unix socket. |
5 | pub struct SocketAddr(pub(super) mio::net::SocketAddr); |
6 | |
7 | impl SocketAddr { |
8 | /// Returns `true` if the address is unnamed. |
9 | /// |
10 | /// Documentation reflected in [`SocketAddr`] |
11 | /// |
12 | /// [`SocketAddr`]: std::os::unix::net::SocketAddr |
13 | pub fn is_unnamed(&self) -> bool { |
14 | self.0.is_unnamed() |
15 | } |
16 | |
17 | /// Returns the contents of this address if it is a `pathname` address. |
18 | /// |
19 | /// Documentation reflected in [`SocketAddr`] |
20 | /// |
21 | /// [`SocketAddr`]: std::os::unix::net::SocketAddr |
22 | pub fn as_pathname(&self) -> Option<&Path> { |
23 | self.0.as_pathname() |
24 | } |
25 | } |
26 | |
27 | impl fmt::Debug for SocketAddr { |
28 | fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { |
29 | self.0.fmt(fmt) |
30 | } |
31 | } |
32 | |