add specialized Buf::chunks_vectored for Take#617
Merged
Darksonn merged 8 commits intotokio-rs:masterfrom Jan 13, 2025
Merged
Conversation
Contributor
Author
|
Just noticed this is a duplicate of #476. Don't have a strong opinion here, please feel free to review and merge either :) |
f8ae0bb to
1482c40
Compare
Member
|
Thank you. This got lost, sorry about that. I'm rebasing it and tweaking it myself since it's been so long. |
Member
|
The test was failing because this is writing to the extra slots in |
cf0477b to
a9ec05d
Compare
10b5341 to
94e5843
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
h2crate usesTakearound the data frames to enforce a maximum frame size, which breaks vectored writes sinceTakedoesn't provide a specializedchunks_vectoredthat calls the underlyingchunks_vectored.To make this work with truncating individual
IoSlices, I needed to resort to a tiny bit ofunsafecode. 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
IoSlicethat 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!