-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 a poll_read_buf shim to tokio-util to mimic now deprecated AsyncRead API #2972
Conversation
Thanks! I would like to see a function with this signature too: pub async fn read_buf<R, B>(
read: &mut R,
buf: &mut B,
) -> io::Result<usize>
where
R: AsyncRead + Unpin,
B: BufMut,
{ It can just internally call EDIT: Added |
8c47179
to
db2acc3
Compare
So I'm guessing this should either take a |
Yeah, it should be async. The |
Added Couldn't find any non-dev dependency |
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 think this is more or less ready.
Co-authored-by: Alice Ryhl <alice@ryhl.io>
While working to migrate a project to
0.3.0
I found uses of the now deprecatedpoll_read_buf
API that needed to be migrated. This turned out to be nontrivial for types implementingBufMut
which does not immediately provide an API to access an underlying contiguous buffer like Chain.This adds a shim for it which provides the old API to ease migrations to
0.3.0
. The naming and shape of the API is preliminary and I'll happily move and rename it to whatever is appropriate if it warrants inclusion. At the very least I'm putting it here in the hope so that people who are currently migrating might find it. It might also be a good idea to provide it as a library function since the generic implementation involves a sprinkle ofunsafe
it would be a shame for people to have to replicate.