1use std::fmt;
2use std::path::Path;
34/// An address associated with a Tokio Unix socket.
5///
6/// This type is a thin wrapper around [`std::os::unix::net::SocketAddr`]. You
7/// can convert to and from the standard library `SocketAddr` type using the
8/// [`From`] trait.
9pub struct SocketAddr(pub(super) std::os::unix::net::SocketAddr);
1011impl SocketAddr {
12/// Returns `true` if the address is unnamed.
13 ///
14 /// Documentation reflected in [`SocketAddr`]
15 ///
16 /// [`SocketAddr`]: std::os::unix::net::SocketAddr
17pub fn is_unnamed(&self) -> bool {
18self.0.is_unnamed()
19 }
2021/// Returns the contents of this address if it is a `pathname` address.
22 ///
23 /// Documentation reflected in [`SocketAddr`]
24 ///
25 /// [`SocketAddr`]: std::os::unix::net::SocketAddr
26pub fn as_pathname(&self) -> Option<&Path> {
27self.0.as_pathname()
28 }
29}
3031impl fmt::Debug for SocketAddr {
32fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
33self.0.fmt(fmt)
34 }
35}
3637impl From<std::os::unix::net::SocketAddr> for SocketAddr {
38fn from(value: std::os::unix::net::SocketAddr) -> Self {
39 SocketAddr(value)
40 }
41}
4243impl From<SocketAddr> for std::os::unix::net::SocketAddr {
44fn from(value: SocketAddr) -> Self {
45 value.0
46}
47}