implement TryFrom<std::net::UdpSocket/TcpListener> for UdpSocket/TcpListener
This allows setting various socket options (e.g. SO_REUSEPORT) before binding to the socket, and also socket passing from the service supervisor (e.g. systemd).
Hey thanks so much for this patch!
For work we encountered a similar situation recently (around mio also), and something that came out of it is that if a std component can't be changed to a mio variant, something terrible has gone wrong, and it's probably safe to abort the process.
Which is to say: I think it'd be entirely reasonable to use From rather than TryFrom for these conversions.
Which is to say: I think it'd be entirely reasonable to use From rather than TryFrom for these conversions.
Let the user fail as they want =)
It will probably be okay, but I didn't feel confident burying .unwrap() in a fundamental library for just a slightly easier use (this is also not something that will be used that often I guess). That being said, I'm happy to change it if your consensus is to go with From trait instead.
Just to clarify - the "👍" means "it's ok to keep it as it is", "please change it to From", or "undecided" ?
I am against .unwrap() in a library code
@vavrusa yeah, I'd prefer if it was From rather than TryFrom. If this fails then something terrible has gone wrong on the mio side, and it's probably best to abort.
@kpp Sorry, but that feels like an arbitrary restriction. If we were to follow that then romio in its current form wouldn't even be able to exist.
Sorry, but that feels like an arbitrary restriction.
It's not. You can add both TryFrom and From, but implement From as try_from().unwrap(). Having only From implemented with .unwrap() is a restriction.