Skip to content
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

Add normal read() / peek() async functions to AsyncBufReadExt #2144

Closed
sdroege opened this issue May 6, 2020 · 5 comments
Closed

Add normal read() / peek() async functions to AsyncBufReadExt #2144

sdroege opened this issue May 6, 2020 · 5 comments
Labels
A-io Area: futures::io C-feature-request

Comments

@sdroege
Copy link
Contributor

sdroege commented May 6, 2020

This would fill the internal buffer until the given amount is reached and then provide access to it. read() could return a value that implements Deref<Target=[u8]> and on Drop consumes the read data, peek() would only provide direct access to an &[u8].

This seems useful to have to allow copy-less operation on AsyncBufRead impls. If they implement AsyncRead in addition, a copy would always be necessary.

Inspired partially by https://boats.gitlab.io/blog/post/io-uring/

@Nemo157
Copy link
Member

Nemo157 commented May 6, 2020

What is a buffered reader to do if the requested amount exceeds the internal buffer size?

@sdroege
Copy link
Contributor Author

sdroege commented May 6, 2020

Return less, just like AsyncRead::read() can return less

@Nemo157
Copy link
Member

Nemo157 commented May 6, 2020

So this could purely be an AsyncBufReadExt sugar around poll_fill_buf + consume, not something implemented for each AsyncBufRead?

peek seems like it would just be the missing AsyncBufReadExt::fill_buf (which IIRC might have lifetime issues).

@sdroege
Copy link
Contributor Author

sdroege commented May 6, 2020

Yes that is exactly what I meant, sorry for not being more clear :)

@sdroege sdroege changed the title Add normal read() / peek() async functions to AsyncBufRead Add normal read() / peek() async functions to AsyncBufReadExt May 6, 2020
@taiki-e
Copy link
Member

taiki-e commented Oct 31, 2020

I think this is addressed by #2225.

@taiki-e taiki-e closed this as completed Oct 31, 2020
@taiki-e taiki-e added the A-io Area: futures::io label Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-io Area: futures::io C-feature-request
Projects
None yet
Development

No branches or pull requests

3 participants