Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socketaddr: implement conversions for tokio and std unix SocketAddr #6868

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tokio/src/net/unix/socketaddr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Loading