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

Conversation

nmathewson
Copy link
Contributor

Implement From to convert tokio::unix::SocketAddr to and from Rust's std::os::unix::net::SocketAddr.

These types were (I'm told) originally separate because mio had a distinct SocketAddr type. This patch makes it possible to convert between them more easily.

Fixes: #6864

Implement `From` to convert `tokio::unix::SocketAddr` to and from
Rust's `std::os::unix::net::SocketAddr`.

These types were (I'm told) originally separate because `mio` had a
distinct `SocketAddr` type.  This patch makes it possible to
convert between them more easily.

Fixes: tokio-rs#6864
@nmathewson
Copy link
Contributor Author

Note: As a forward-compatibility measure, if we think that someday std and tokio might diverge again here, we could implement TryFrom instead.

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-net Module: tokio/net labels Sep 25, 2024
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Can you add a note to the documentation of the SocketAddr struct that this conversion is possible?

@nmathewson
Copy link
Contributor Author

Thanks. Can you add a note to the documentation of the SocketAddr struct that this conversion is possible?

Done! My documentation isn't always the greatest, so please feel do free to make any suggestions about how to clarify it.

Co-authored-by: Alice Ryhl <aliceryhl@google.com>
@Darksonn Darksonn enabled auto-merge (squash) September 25, 2024 13:40
@Darksonn Darksonn merged commit 623928e into tokio-rs:master Sep 25, 2024
81 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-net Module: tokio/net
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can we convert unix::SocketAddr to/from std::os::unix::net::SocketAddr?
2 participants