-
Notifications
You must be signed in to change notification settings - Fork 341
Add UdpSocket::{poll_recv_from, poll_send_to}
#636
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
Conversation
a08814c
to
44b5d8c
Compare
@demimarie-parity hi, thanks for opening this PR! -- This is a bit of a design departure from where we were at. The team has been away over the holidays, but we're meeting up again next week to catch up and discuss future directions. I'll make sure we discuss this PR then! Also if Parity is experimenting with async-std, I'm sure I speak for the team we would love to hear more about the directions you're taking to ensure we can support you. We'd love to see you succeed! |
I believe pub fn poll_recv_from(
&self,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<io::Result<(usize, SocketAddr)>> {
Pin::new(&mut self.recv_from(buf)).poll(cx)
} So you could simply do |
This is needed for QUIC implementations based on async-std. It could be done with `UdpSocket::{recv_from, send_to}`, but this requires boxing, reference counting, and `unsafe` code.
3d456aa
to
2a9e347
Compare
@stjepang Two caveats:
|
Pin is a zero-sized type, and LLVM is incredibly good at inlining when compiling Rust with
Do you have any suggestions to what this could look like? The pinning chapter in the async book goes into this a bit. And so do the Maybe there is something there we could do to improve this? Or do you think an async-std specific addition would be more helpful? |
The biggest issue is that async functions don’t implement |
@demimarie-parity pin-project and pin-project-lite are the recommended ways of replacing the unsafe code with safe compile-time invariant checks. The stdlib doesn't include either, but the Pin API was very much designed with these abstractions in mind. Either way, I think we can have a resolution for this issue. Going to go ahead and close this PR and #634! |
This is needed for QUIC implementations based on async-std. It could be
done with
UdpSocket::{recv_from, send_to}
, but this requires boxing,reference counting, and
unsafe
code.