You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default implementation of Write::write_vectored conservatively calls write with the first slice only. This can lead to surprising behavior when developing code that performs vectored writes against memory/fake destinations that don't implement write_vectored themselves, and only the first slice shows up.
This PR adds a function that calls write on all provided slices, which can be a more convenient default, at least for in-memory destinations where the call costs are cheap. It then uses it in a couple of our buffer types.
Tweaked the implementation a little bit. Previously, if an error is encountered, partial progress would be reported only when the error kind is WriteZero. However, I think we should always report partial progress when an error is encountered, regardless of type (with the exception of Interrupted, for which retrying is idiomatic), otherwise that information is lost. Of course, whenever we report partial progress in response to an error then we are losing the error information instead, but in general the next write attempt should trigger the same error again.
Note that these distinctions aren't meaningful when used directly by memory buffers, which is all we are doing today. Just making the impl a little more robust in case it finds its way into a middleware atop a socket or something.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default implementation of Write::write_vectored conservatively calls
writewith the first slice only. This can lead to surprising behavior when developing code that performs vectored writes against memory/fake destinations that don't implementwrite_vectoredthemselves, and only the first slice shows up.This PR adds a function that calls
writeon all provided slices, which can be a more convenient default, at least for in-memory destinations where the call costs are cheap. It then uses it in a couple of our buffer types.