Skip to content

Implement poll_read and poll_write for UdpSocket #634

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

Closed
Demi-Marie opened this issue Dec 17, 2019 · 6 comments
Closed

Implement poll_read and poll_write for UdpSocket #634

Demi-Marie opened this issue Dec 17, 2019 · 6 comments
Labels
enhancement New feature or request

Comments

@Demi-Marie
Copy link

Currently, it is difficult to use a UdpSocket in an AsyncWrite implementation, as it does not expose any low-level methods that return Poll.

@k-nasa k-nasa added the enhancement New feature or request label Dec 18, 2019
@Demi-Marie
Copy link
Author

Would a high-quality PR implementing this be accepted?

@ghost
Copy link

ghost commented Jan 13, 2020

We don't really expose any poll_* methods. But note that you can poll futures returned by read() and write() -- would something like this work for you?

Pin::new(&mut socket.read(buf)).poll(cx);

@yoshuawuyts
Copy link
Contributor

Related PR: #636

@Demi-Marie
Copy link
Author

We don't really expose any poll_* methods. But note that you can poll futures returned by read() and write() -- would something like this work for you?

Pin::new(&mut socket.read(buf)).poll(cx);

It does not compile because the return value of socket.read is not Unpin.

@tomaka
Copy link

tomaka commented Jan 28, 2020

Something like that should work:

let mut fut = socket.read(buf);
futures::pin_mut!(fut);
fut.poll(cx)

@Demi-Marie
Copy link
Author

@tomaka thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants