Refine Guard* APIs and implementation #11354
Merged
Merged
Conversation
Member
Author
|
|
e6a7528 to
10226e1
Compare
fitzgen
approved these changes
Jul 30, 2025
Member
fitzgen
left a comment
There was a problem hiding this comment.
LGTM, although I am not super familiar with this code
This is a follow-up to bytecodealliance#11325 with a number of cosmetic changes about the shape of the API and structure of the internals: * `{Stream,Future}{Reader,Writer}::guard` is now an alternative constructor to `Guard*::new` (import fewer types). * Internally `WithAccessor` and `DropWithStore` are removed in favor of direct `Drop for Guard*` impls. * An `Option` is used to replace `ManuallyDrop` and `unsafe` code. * `{Stream,Future}{Reader,Writer}::close{,_with}` now take `&mut self` instead of `self` to be more composable with `&mut self` arguments during `Drop` for other structures (e.g. build-your-own drop-with-store). * The type parameters on `Guard*` are simplified to just `T`, the future or stream payload, and `A: AsAccessor`. This helps cut down on the complexity of signatures. * `Guard*` types now have `into_{stream,future}` as an alternative to `.into()` which doesn't require type annotations.
10226e1 to
3ee24b4
Compare
dicej
approved these changes
Jul 31, 2025
bongjunj
pushed a commit
to prosyslab/wasmtime
that referenced
this pull request
Oct 20, 2025
This is a follow-up to bytecodealliance#11325 with a number of cosmetic changes about the shape of the API and structure of the internals: * `{Stream,Future}{Reader,Writer}::guard` is now an alternative constructor to `Guard*::new` (import fewer types). * Internally `WithAccessor` and `DropWithStore` are removed in favor of direct `Drop for Guard*` impls. * An `Option` is used to replace `ManuallyDrop` and `unsafe` code. * `{Stream,Future}{Reader,Writer}::close{,_with}` now take `&mut self` instead of `self` to be more composable with `&mut self` arguments during `Drop` for other structures (e.g. build-your-own drop-with-store). * The type parameters on `Guard*` are simplified to just `T`, the future or stream payload, and `A: AsAccessor`. This helps cut down on the complexity of signatures. * `Guard*` types now have `into_{stream,future}` as an alternative to `.into()` which doesn't require type annotations.
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.
This is a follow-up to #11325 with a number of cosmetic changes about
the shape of the API and structure of the internals:
{Stream,Future}{Reader,Writer}::guardis now an alternativeconstructor to
Guard*::new(import fewer types).WithAccessorandDropWithStoreare removed in favor ofdirect
Drop for Guard*impls.Optionis used to replaceManuallyDropandunsafecode.{Stream,Future}{Reader,Writer}::close{,_with}now take&mut selfinstead of
selfto be more composable with&mut selfargumentsduring
Dropfor other structures (e.g. build-your-owndrop-with-store).
Guard*are simplified to justT, the futureor stream payload, and
A: AsAccessor. This helps cut down on thecomplexity of signatures.
Guard*types now haveinto_{stream,future}as an alternative to.into()which doesn't require type annotations.