diff --git a/tokio/src/net/unix/socketaddr.rs b/tokio/src/net/unix/socketaddr.rs index 62ed4294d45..063f4c53faf 100644 --- a/tokio/src/net/unix/socketaddr.rs +++ b/tokio/src/net/unix/socketaddr.rs @@ -2,6 +2,10 @@ use std::fmt; use std::path::Path; /// An address associated with a Tokio Unix socket. +/// +/// This type is a thin wrapper around [`std::os::unix::net::SocketAddr`]. You +/// can convert to and from the standard library `SocketAddr` type using the +/// [`From`] trait. pub struct SocketAddr(pub(super) std::os::unix::net::SocketAddr); impl SocketAddr { @@ -29,3 +33,15 @@ impl fmt::Debug for SocketAddr { self.0.fmt(fmt) } } + +impl From for SocketAddr { + fn from(value: std::os::unix::net::SocketAddr) -> Self { + SocketAddr(value) + } +} + +impl From for std::os::unix::net::SocketAddr { + fn from(value: SocketAddr) -> Self { + value.0 + } +}