-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
add write_all_vectored to AsyncWriteExt
#7768
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
base: master
Are you sure you want to change the base?
Conversation
write_all_vectored to AsyncWriteExt (#3679)write_all_vectored to AsyncWriteExt
16eed02 to
34aa2a3
Compare
|
We could implement |
|
I thought that as well but I saw |
martin-g
left a comment
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.
If this PR will be finished then it also needs an IT test.
| /// &mut self, | ||
| /// bufs: &mut [IoSlice<'_>], | ||
| /// ) -> io::Result<()> { | ||
| /// let mut pos = 0; |
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.
The pos variable is never used. Maybe return it as a result to make the example more complete ?!
|
|
||
| pub(crate) fn write_all_vectored<'a, 'b, W>( | ||
| writer: &'a mut W, | ||
| bufs: &'a mut [IoSlice<'b>], |
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.
The signature in std is a bit different:
| bufs: &'a mut [IoSlice<'b>], | |
| bufs: &'a mut &'a mut [IoSlice<'b>], |
| let me = self.project(); | ||
| while !me.bufs.is_empty() { | ||
| let n = ready!(Pin::new(&mut *me.writer).poll_write_vectored(cx, me.bufs))?; | ||
| if n == 0 { |
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 needs extra care for the case when all bufs are empty. In this case 0 is not really an error.
Same improvement should be done in the (ignored) sample code in async_write_ext.rs
Motivation
Closes #3679
Was recently looking for
write_all_vectoredand found it missing, went to add it before realizing the MSRV is not there yet.I thought I'd submit this anyway, when the MSRV version moves ahead you can accept, or we could copy in the
IoSlice::advance_slicesfn until that happens?Solution
Tried to follow existing pattern for
write_xmethods