-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
io: add copy_buf
#2884
io: add copy_buf
#2884
Conversation
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
#[derive(Debug)] | ||
#[must_use = "futures do nothing unless you `.await` or poll them"] | ||
pub struct CopyBuf<'a, R: ?Sized, W: ?Sized> { | ||
reader: &'a mut R, |
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.
FYI: futures
's copy_buf
takes the reader by value to allow !Unpin
reader. (This is only done in the reader as only the reader is exhausted by this operation.)
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.
On the other hand, taking it by reference is consistent with Tokio's copy
. In either case, !Unpin
readers can still be used here if combined with tokio::pin!
.
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.
On the other hand, taking it by reference is consistent with Tokio's
copy
.
Yeah, if copy_buf
takes the reader by value, copy
also needs to take the reader by value for consistency.
This is fine w/ me, but based on #2428, it looks like |
Note that the |
Motivation
Add copy_buf function like the one from futures, but with tokio's async io traits.
Solution
Add
io::copy_buf
function.Fix #2797
Signed-off-by: Zahari Dichev zaharidichev@gmail.com