add specialized Buf::chunks_vectored
for Take
#617
+78
−0
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
h2
crate usesTake
around the data frames to enforce a maximum frame size, which breaks vectored writes sinceTake
doesn't provide a specializedchunks_vectored
that calls the underlyingchunks_vectored
.To make this work with truncating individual
IoSlice
s, I needed to resort to a tiny bit ofunsafe
code. There is a PR open (rust-lang/rust#111277) which will alleviate the need for it, but that hasn't landed yet (so unlikely to be stable any time soon).An alternative could be to just remove rather than truncate any
IoSlice
that crosses the limit threshold, which could be accomplished without any unsafe code. However, that might break the following guarantee documented onchunks_vectored
: "If chunk_vectored does not fill every entry in dst, then dst is guaranteed to contain all remaining slices in `self."Happy to go either route, let me know what you think!