Add support for async/streams/futures to Rust generator#1081
Closed
dicej wants to merge 1 commit intobytecodealliance:mainfrom
Closed
Add support for async/streams/futures to Rust generator#1081dicej wants to merge 1 commit intobytecodealliance:mainfrom
dicej wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
This adds support for generating bindings which use the [Async ABI](https://github.com/WebAssembly/component-model/blob/main/design/mvp/Async.md) along with the [`stream`, `future`, and `error-context`](WebAssembly/component-model#405) types. By default, normal synchronous bindings are generated, but the user may opt-in to async bindings for all or some of the imported and/or exported functions in the target world and interfaces -- provided the default-enabled `async` feature is enabled. In addition, we generate `StreamPayload` and/or `FuturePayload` trait implementations for any types appearing as the `T` in `stream<T>` or `future<T>` in the WIT files, respectively. That enables user code to call `new_stream` or `new_future` to create `stream`s or `future`s with those payload types, then write to them, read from them, and/or pass the readable end as a parameter to a component import or return value of a component export. Note that I've added new `core::abi::Instruction` enum variants to handle async lifting and lowering, but they're currently tailored to the Rust generator and will probably change somewhat as we add support for other languages. This does not include any new tests; I'll add those in a follow-up commit. Signed-off-by: Joel Dice <[email protected]>
Collaborator
Author
|
Oops, forgot to make this a "draft" PR, and GitHub won't let me change it 🤦 . I'll close this and open another one. |
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 adds support for generating bindings which use the Async ABI along with the
stream,future, anderror-contexttypes.By default, normal synchronous bindings are generated, but the user may opt-in to async bindings for all or some of the imported and/or exported functions in the target world and interfaces -- provided the default-enabled
asyncfeature is enabled.In addition, we generate
StreamPayloadand/orFuturePayloadtrait implementations for any types appearing as theTinstream<T>orfuture<T>in the WIT files, respectively. That enables user code to callnew_streamornew_futureto createstreams orfutures with those payload types, then write to them, read from them, and/or pass the readable end as a parameter to a component import or return value of a component export.Note that I've added new
core::abi::Instructionenum variants to handle async lifting and lowering, but they're currently tailored to the Rust generator and will probably change somewhat as we add support for other languages.This does not include any new tests; I'll add those in a follow-up commit.
This is ready for review, but I'll leave it in draft mode until the following are complete:
wasm-toolsonce Add support for async ABI, futures, streams, and errors wasm-tools#1895 is merged and released