Skip to content
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

add specialized Buf::chunks_vectored for Take #617

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

srijs
Copy link

@srijs srijs commented Jun 11, 2023

The h2 crate uses Take around the data frames to enforce a maximum frame size, which breaks vectored writes since Take doesn't provide a specialized chunks_vectored that calls the underlying chunks_vectored.

To make this work with truncating individual IoSlices, I needed to resort to a tiny bit of unsafe 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 on chunks_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!

@srijs
Copy link
Author

srijs commented Jun 12, 2023

Just noticed this is a duplicate of #476. Don't have a strong opinion here, please feel free to review and merge either :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant