mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-20 00:00:08 +02:00
net: add conversions for unix SocketAddr (#6868)
This commit is contained in:
@@ -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<std::os::unix::net::SocketAddr> for SocketAddr {
|
||||
fn from(value: std::os::unix::net::SocketAddr) -> Self {
|
||||
SocketAddr(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<SocketAddr> for std::os::unix::net::SocketAddr {
|
||||
fn from(value: SocketAddr) -> Self {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user