tokio/net/unix/
socketaddr.rs1use std::fmt;
2use std::path::Path;
3
4#[derive(Clone)]
10pub struct SocketAddr(pub(super) std::os::unix::net::SocketAddr);
11
12impl SocketAddr {
13 pub fn is_unnamed(&self) -> bool {
19 self.0.is_unnamed()
20 }
21
22 pub fn as_pathname(&self) -> Option<&Path> {
28 self.0.as_pathname()
29 }
30
31 #[cfg(any(target_os = "linux", target_os = "android"))]
39 #[cfg_attr(docsrs, doc(cfg(any(target_os = "linux", target_os = "android"))))]
40 pub fn as_abstract_name(&self) -> Option<&[u8]> {
41 #[cfg(target_os = "android")]
42 use std::os::android::net::SocketAddrExt;
43 #[cfg(target_os = "linux")]
44 use std::os::linux::net::SocketAddrExt;
45
46 self.0.as_abstract_name()
47 }
48}
49
50impl fmt::Debug for SocketAddr {
51 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
52 self.0.fmt(fmt)
53 }
54}
55
56impl From<std::os::unix::net::SocketAddr> for SocketAddr {
57 fn from(value: std::os::unix::net::SocketAddr) -> Self {
58 SocketAddr(value)
59 }
60}
61
62impl From<SocketAddr> for std::os::unix::net::SocketAddr {
63 fn from(value: SocketAddr) -> Self {
64 value.0
65 }
66}