Draft
Conversation
Some functions are specifically designed to take in objects implementing `std::io` traits while guaranteeing that they don't lose state when `WouldBlock` is present (as opposed to e.g. `write_all` which does lose the state). Those function could thus be used to construct futures but it requires some boilerplate. This commit adds a few utility adapters to help reduce the boilerplate by implementing the vast majority of it. The consumer of these adapters can pass a writer and a fairly simple closure to a method to obtain a `Future` which will process the desired operation.
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.
I felt like I could better express myself by making a PR than trying to explain it in an issue, so here's a draft. If you agree with inclusion of this feature I will add the
Read/BufReadimpls and tests.Motivation
Some functions are specifically designed to take in objects implementing
std::iotraits while guaranteeing that they don't lose state whenWouldBlockis present (as opposed to e.g.write_allwhich does lose the state). Those function could thus be used to construct futures but it requires some boilerplate.Solution
This PR adds a few utility adapters to help reduce the boilerplate by implementing the vast majority of it. The consumer of these adapters can pass a writer and a fairly simple closure to a method to obtain a
Futurewhich will process the desired operation.I'm seeking feedback here and will update the PR as needed.