tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
26.59k stars 2.45k forks source link

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

Closed nmathewson closed 1 week ago

nmathewson commented 1 week ago

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

nmathewson commented 1 week ago

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

nmathewson commented 1 week ago

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.