-
Notifications
You must be signed in to change notification settings - Fork 708
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
RFC: Stop using std::net types (TcpStream / UdpSocket) #146
Comments
You forgot Do you think that the |
@Hoverbear I have mentioned it and I believe they will stabilize it, but not until 1.0 Final would be my guess. If |
I would rather stay on nightlies and use the |
Requiring nightlies after 1.0 would greatly limit |
I like the idea of one library that support the same platforms rust itself supports over using the std types. |
I'm in favor of this; at the moment lack of Windows support is the only thing keeping me from using |
We are using mio in a couple of projects. All of them will stay on nightlies after 1.0, at least until compiler plugins are stable. Windows support is not important for us, but I guess it would be nice to have for some people. (without additional overhead for *nix part). But there are some things that I would prefer be different. After last mio reform my colleagues asked me a lot of questions about code like this match sock.read_slice(...) {
Ok(Some(n)) => { .. },
Ok(None) => { .. },
Err(e) => { .. },
} It's very confusing and non intuitive. I believe Option is not ideal way of communicating WouldBlock. Smth like this would be great. match sock.read_slice(...) {
Ok(n) => { .. },
Err(Mio::WouldBlock) => { .. },
Err(Mio::Eof) => { .. },
Err(e) => { .. },
} Explicit eof instead of n == 0 would be great too. With Result<_, mio::Error> it will be possible again. |
@rozaliev I thought a bunch about how to communicate If all mio sockets are assumed to be non-blocking, match sock.read_slice(...) {
Ok(NonBlocK::Ready(n)) => { .. },
Ok(NonBlock::WouldBlock) => { .. },
Err(e) => { .. },
} |
I personally would prefer if we reused |
I think I also personally prefer the Anyway, got Mio running on Rust 1.0 beta w/o these changes, so there isn't a huge rush now. I think version 0.4.0 will target windows support, which will require some of what I proposed initially. I'll try to post a more in depth windows support plan when I have a moment. |
Out of interest, what would |
The versions in mio would probably be hard coded to be non-blocking. However, there could be conversions between |
Would this affect Mio's ability to interoperate with openssl crate's |
@jnicholls It shouldn't make it harder. I believe it would be possible for Mio to work w/ a non-block SSL stream type. We could discuss it further on the #mio IRC channel. |
I'm going to close this in favor of #155. Trying to keep things clean... |
I'm considering moving away from using
std::net
types in favor of re-implementing them in Mio. Mio started off using this strategy, then attempted to usestd::net
types when available. Mio introducedNonBlock<_>
in order to differentiate between blockingstd
sockets and non-blockingstd
sockets.I am considering going back to the original strategy in order to achieve a few things.
First, I would like to get mio working on stable. Unfortunately,
Error::from_os_error
is not stable, which means that it is impossible to create an error value without allocating. This makes me wary of relying onstd::net
types in the future to be able to support the features that mio wants to.Second, I have put a lot more though into windows support. My opinions re: windows support have changed over time. I thought that it would be best to leave windows support to a different library, however, I started writing this library and spent a lot of time with the windows IOCP APIs and I believe that it would be possible to support windows equivalently with some minor API tweaks (backwards compatible). However, to do this, all the network types would need to be implemented in mio.
Also, if mio owns all the types, there wouldn't be much use to have
NonBlock<_>
anymore since all the types in mio could be non-blocking by default, but this is an optional change.So, the strategy would be:
TcpStream
&TcpListener
into miostd::io::Error
in favor ofmio::Error
<NonBlock<_>>
(optional)The text was updated successfully, but these errors were encountered: