-
Notifications
You must be signed in to change notification settings - Fork 755
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
feat: Move std::net
dependencies to sys::net
.
#1481
Conversation
`mio` provides this great architecture where `mio::net` defines user-friendly wrappers to system backends, i.e. `sys` modules like `sys::unix`, `sys::windows` and `sys::shell`. At every step, it's assumed that `std::net` is available. However, depending on the backend a user would like to implement, `std::net` might not be present. For example, it's assumed that `std::net::{TcpListener, TcpStream}` are always available. That's not always true. This patch moves the responsability to the backends to _declare_ —or basically to _re-export_!— some types from `std::net`, such as: * `std::net::TcpListener`, * `std::net::TcpStream`, * `std::net::UdpSocket`, * `std::net::SocketAddr`, * `std::net::{SocketAddrV4,SocketAddrV6}`, * `std::net::{Ipv4Addr, Ipv6Addr}`. To achieve that, all of those types above related to `std::net` are now in `sys::net`, those related to TCP are now in `sys::tcp`, and finally those related to UDP are now in `sys::udp`. It's actually consistent with types that were previously implement in `sys` like `sys::tcp::TcpSocket`. With this patch, `mio::net` has no more dependency to `std::net`. Everything comes from `sys`.
Note: The |
This is not true, only when the Also I'm not sure what this change actually accomplishes, could you elaborate on what use cases this helps? |
Yeah correct, I was too prompt in my explanation, sorry for that.
Everytime But I'm working on an experimental WASI support, and thus I need to implement custom Thoughts? |
But isn't that the same as having
I know wasi doesn't support sockets currently (or at least last I checked), but can't you turn of the
Also I have an wip (and now outdated) port of Mio to wasm in pr #1395. |
If But by “moving the Basically, this patch replaces the imports from :-) |
But if std lib doesn't provide
I can read that from the code, but what I want to know is what benefit does this bring to Mio over the current situation? As far as I can tell wasm doesn't have a way to create a socket currently, so even with this patch accept the |
Since I'm still not convinced of the usefulness of this change I'm going to close it. @Hywan if you still want to continue with this feel free to reopen. |
:-) |
mio
provides this great architecture wheremio::net
definesuser-friendly wrappers to system backends, i.e.
sys
modules likesys::unix
,sys::windows
andsys::shell
.At every step, it's assumed that
std::net
is available. However,depending on the backend a user would like to implement,
std::net
might not be present. For example, it's assumed that
std::net::{TcpListener, TcpStream}
are always available.That's not always true.
This patch moves the responsability to the backends to declare —or
basically to re-export!— some types from
std::net
, such as:std::net::TcpListener
,std::net::TcpStream
,std::net::UdpSocket
,std::net::SocketAddr
,std::net::{SocketAddrV4,SocketAddrV6}
,std::net::{Ipv4Addr, Ipv6Addr}
.To achieve that, all of those types above related to
std::net
arenow in
sys::net
, those related to TCP are now insys::tcp
, andfinally those related to UDP are now in
sys::udp
.It's actually consistent with types that were previously implemented in
sys
likesys::tcp::TcpSocket
.With this patch,
mio::net
has no more dependency tostd::net
. Everything comes fromsys
.