Skip to content

Commit 8ebfc1e

Browse files
committed
Add support for async/streams/futures to Rust generator
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 <joel.dice@fermyon.com>
1 parent b0db20b commit 8ebfc1e

File tree

27 files changed

+2556
-289
lines changed

27 files changed

+2556
-289
lines changed

Cargo.lock

Lines changed: 115 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ indexmap = "2.0.0"
3232
prettyplease = "0.2.20"
3333
syn = { version = "2.0", features = ["printing"] }
3434

35-
wasmparser = "0.219.0"
36-
wasm-encoder = "0.219.0"
37-
wasm-metadata = "0.219.0"
38-
wit-parser = "0.219.0"
39-
wit-component = "0.219.0"
35+
wasmparser = { git = "https://github.com/dicej/wasm-tools", branch = "async" }
36+
wasm-encoder = { git = "https://github.com/dicej/wasm-tools", branch = "async" }
37+
wasm-metadata = { git = "https://github.com/dicej/wasm-tools", branch = "async" }
38+
wit-parser = { git = "https://github.com/dicej/wasm-tools", branch = "async" }
39+
wit-component = { git = "https://github.com/dicej/wasm-tools", branch = "async" }
4040

4141
wit-bindgen-core = { path = 'crates/core', version = '0.34.0' }
4242
wit-bindgen-c = { path = 'crates/c', version = '0.34.0' }
@@ -74,6 +74,7 @@ default = [
7474
'go',
7575
'csharp',
7676
'moonbit',
77+
'async',
7778
]
7879
c = ['dep:wit-bindgen-c']
7980
rust = ['dep:wit-bindgen-rust']
@@ -83,6 +84,7 @@ go = ['dep:wit-bindgen-go']
8384
csharp = ['dep:wit-bindgen-csharp']
8485
csharp-mono = ['csharp']
8586
moonbit = ['dep:wit-bindgen-moonbit']
87+
async = ["wit-bindgen-rust/async"]
8688

8789
[dev-dependencies]
8890
heck = { workspace = true }

0 commit comments

Comments
 (0)