-
-
Notifications
You must be signed in to change notification settings - Fork 394
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(quinn,quinn-udp): Introduce net
feature to allow disabling socket2
and std::net::UdpSocket
dependencies
#2037
base: main
Are you sure you want to change the base?
Conversation
/// Abstracts I/O and timer operations for runtime independence | ||
pub trait Runtime: Send + Sync + Debug + 'static { | ||
/// Construct a timer that will expire at `i` | ||
fn new_timer(&self, i: Instant) -> Pin<Box<dyn AsyncTimer>>; | ||
/// Drive `future` to completion in the background | ||
fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>); | ||
/// Convert `t` into the socket type used by this runtime | ||
#[cfg(feature = "net")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I feel like trait methods that appear/disappear based on a Cargo feature aren't great. Are you still using the Runtime
trait in your WASM setup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone back and forth between having this gated on a feature and having this gated on the wasm32-unknown-unknown
target.
Another option is to keep this method but then error out in all cases if invoked. This looks clean on the quinn
side, but is error prone when e.g. some new quinn
contribution suddenly makes use of the wrap_udp_socket
fn outside of the net
feature.
4fa89dd
to
a934ab4
Compare
I realized this PR is missing some rationale, so I'm writing this on the top level for better visibility:
This was one of the first things I was thinking initially, too. The only definitions that The fundamental problem IMO is that The solution would be to separate out the type definitions of
Yes, there's no way of using The alternative would be integrating with |
a934ab4
to
a12a85a
Compare
…cket2` and `std::net::UdpSocket` dependencies
a12a85a
to
8b20acd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think this all makes sense. Thanks!
Changes
net
feature toquinn-udp
andquinn
socket2
dependency as optional (only enabled withnet
feature)std::net::UdpSocket
(e.g.Runtime::wrap_udp_socket
orEndpoint::rebind
) becomes gated bynet
featureweb_time
dependency toquinn-udp
andquinn
that is only enabled inwasm32-unknown-unknown
targetNote: The
net
feature will be implied by currentruntime-*
features.Testing
Runtime
implementation in the browser and nodejs.I'm not contributing this test (yet?) as discussed.
(import "env" ...)
in thequinn
.wasm
file when built.This is a good, even if not quite sufficient effort in making sure the Wasm build doesn't break.