Skip to content

Support "linear writes" in Rust future bindings - #1306

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
alexcrichton:future-writer-always-writes
May 27, 2025
Merged

Support "linear writes" in Rust future bindings#1306
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
alexcrichton:future-writer-always-writes

Conversation

@alexcrichton

Copy link
Copy Markdown
Member

To account for WebAssembly/wasip3-prototyping#172 and WebAssembly/component-model#521 the Rust bindings need to take into account that a future writer cannot be dropped without actually writing something. To model this futures now must be created with a thunk that creates the default value to be sent. This value is only used if another value was not otherwise written.

Closes #1304

To account for WebAssembly/wasip3-prototyping#172 and
WebAssembly/component-model#521 the Rust bindings need to take into
account that a future writer cannot be dropped without actually writing
something. To model this futures now must be created with a thunk that
creates the default value to be sent. This value is only used if another
value was not otherwise written.

Closes bytecodealliance#1304
@alexcrichton
alexcrichton requested a review from dicej May 27, 2025 20:58
@alexcrichton

Copy link
Copy Markdown
Member Author

For now tests are "updated enough" to pass but I suspect that more tests will need to be updated once the host is also enforcing this. Notably I suspect some C tests will need to be updated.

@alexcrichton
alexcrichton enabled auto-merge May 27, 2025 21:09
@alexcrichton
alexcrichton added this pull request to the merge queue May 27, 2025
Merged via the queue into bytecodealliance:main with commit b98f2e8 May 27, 2025
@alexcrichton
alexcrichton deleted the future-writer-always-writes branch May 27, 2025 21:32
rvolosatovs added a commit to bytecodealliance/wrpc that referenced this pull request Jun 23, 2026
Merge upstream wit-bindgen 0.42.0 into the vendored bindgen subtree.

- Bump wit-bindgen-core 0.41 -> 0.42 and wit-parser 0.227 -> 0.230.
- Adapt to the wit-parser 0.230 API break: `TypeDefKind` gained a
  `FixedSizeList(Type, u32)` variant. Handle it in the introspection async-path
  walk like a `List` (element indexed by a wildcard path), and add arms to the
  Rust and Go generators' type/codec matches. Full fixed-size-list code
  generation is not supported yet (upstream adds Rust support in bytecodealliance/wit-bindgen#1277, ported
  later at 0.52), so the generator arms panic with an "unsupported" message;
  no fixture exercises them.
- Port upstream features bytecodealliance/wit-bindgen#1244 + bytecodealliance/wit-bindgen#1270 (`serde::Deserialize` for the bindgen
  config): gate `serde::Deserialize` derives on `Opts` (`serde(default,
  rename_all = "kebab-case")`) and `WithOption` (`rename_all = "kebab-case"`)
  behind a new optional `serde` feature, matching upstream. wRPC has neither
  `ExportKey`/`AsyncConfig`/`Ownership` config types nor an `async_` option, so
  only `Opts`/`WithOption` apply.

Non-carries (not applicable to wRPC, dropped from the merge):
- more `wit-bindgen test` subcommand backends (`crates/test/src/{csharp,
  moonbit}.rs`, `crates/test/LICENSE-*`) and the new `tests/runtime-async/`
  guest runtime test tree; wRPC keeps its own `wrpc-test` crate.
- the async-task / futures-stream-ABI refactors (bytecodealliance/wit-bindgen#1233/bytecodealliance/wit-bindgen#1241/bytecodealliance/wit-bindgen#1249/bytecodealliance/wit-bindgen#1260/bytecodealliance/wit-bindgen#1264/
  bytecodealliance/wit-bindgen#1268/bytecodealliance/wit-bindgen#1278/bytecodealliance/wit-bindgen#1279/bytecodealliance/wit-bindgen#1247/bytecodealliance/wit-bindgen#1240/bytecodealliance/wit-bindgen#1291/bytecodealliance/wit-bindgen#1306 etc.) and bytecodealliance/wit-bindgen#1214's canonical-ABI
  guest-code warning squashing do not apply to wRPC's transport-stub generator.

rust codegen (237) and go codegen (79) tests pass; `cargo clippy --workspace`
(and `--features serde`) and `cargo doc --workspace` are clean; wasmtime and all
examples build.

Assisted-by: claude:claude-opus-4-8
Upstream diff: bytecodealliance/wit-bindgen@v0.41.0...v0.42.0
rvolosatovs added a commit to bytecodealliance/wrpc that referenced this pull request Jun 23, 2026
Merge upstream wit-bindgen 0.42.0 into the vendored bindgen subtree.

- Bump wit-bindgen-core 0.41 -> 0.42 and wit-parser 0.227 -> 0.230.
- Adapt to the wit-parser 0.230 API break: `TypeDefKind` gained a
  `FixedSizeList(Type, u32)` variant. Handle it in the introspection async-path
  walk like a `List` (element indexed by a wildcard path), and add arms to the
  Rust and Go generators' type/codec matches. Full fixed-size-list code
  generation is not supported yet (upstream adds Rust support in bytecodealliance/wit-bindgen#1277, ported
  later at 0.52), so the generator arms panic with an "unsupported" message;
  no fixture exercises them.
- Port upstream features bytecodealliance/wit-bindgen#1244 + bytecodealliance/wit-bindgen#1270 (`serde::Deserialize` for the bindgen
  config): gate `serde::Deserialize` derives on `Opts` (`serde(default,
  rename_all = "kebab-case")`) and `WithOption` (`rename_all = "kebab-case"`)
  behind a new optional `serde` feature, matching upstream. wRPC has neither
  `ExportKey`/`AsyncConfig`/`Ownership` config types nor an `async_` option, so
  only `Opts`/`WithOption` apply.

Non-carries (not applicable to wRPC, dropped from the merge):
- more `wit-bindgen test` subcommand backends (`crates/test/src/{csharp,
  moonbit}.rs`, `crates/test/LICENSE-*`) and the new `tests/runtime-async/`
  guest runtime test tree; wRPC keeps its own `wrpc-test` crate.
- the async-task / futures-stream-ABI refactors (bytecodealliance/wit-bindgen#1233/bytecodealliance/wit-bindgen#1241/bytecodealliance/wit-bindgen#1249/bytecodealliance/wit-bindgen#1260/bytecodealliance/wit-bindgen#1264/
  bytecodealliance/wit-bindgen#1268/bytecodealliance/wit-bindgen#1278/bytecodealliance/wit-bindgen#1279/bytecodealliance/wit-bindgen#1247/bytecodealliance/wit-bindgen#1240/bytecodealliance/wit-bindgen#1291/bytecodealliance/wit-bindgen#1306 etc.) and bytecodealliance/wit-bindgen#1214's canonical-ABI
  guest-code warning squashing do not apply to wRPC's transport-stub generator.

rust codegen (237) and go codegen (79) tests pass; `cargo clippy --workspace`
(and `--features serde`) and `cargo doc --workspace` are clean; wasmtime and all
examples build.

Assisted-by: claude:claude-opus-4-8
Upstream diff: bytecodealliance/wit-bindgen@v0.41.0...v0.42.0
rvolosatovs added a commit to bytecodealliance/wrpc that referenced this pull request Jun 23, 2026
Merge upstream wit-bindgen 0.42.0 into the vendored bindgen subtree.

- Bump wit-bindgen-core 0.41 -> 0.42 and wit-parser 0.227 -> 0.230.
- Adapt to the wit-parser 0.230 API break: `TypeDefKind` gained a
  `FixedSizeList(Type, u32)` variant. Handle it in the introspection async-path
  walk like a `List` (element indexed by a wildcard path), and add arms to the
  Rust and Go generators' type/codec matches. Full fixed-size-list code
  generation is not supported yet (upstream adds Rust support in bytecodealliance/wit-bindgen#1277, ported
  later at 0.52), so the generator arms panic with an "unsupported" message;
  no fixture exercises them.
- Port upstream features bytecodealliance/wit-bindgen#1244 + bytecodealliance/wit-bindgen#1270 (`serde::Deserialize` for the bindgen
  config): gate `serde::Deserialize` derives on `Opts` (`serde(default,
  rename_all = "kebab-case")`) and `WithOption` (`rename_all = "kebab-case"`)
  behind a new optional `serde` feature, matching upstream. wRPC has neither
  `ExportKey`/`AsyncConfig`/`Ownership` config types nor an `async_` option, so
  only `Opts`/`WithOption` apply.

Non-carries (not applicable to wRPC, dropped from the merge):
- more `wit-bindgen test` subcommand backends (`crates/test/src/{csharp,
  moonbit}.rs`, `crates/test/LICENSE-*`) and the new `tests/runtime-async/`
  guest runtime test tree; wRPC keeps its own `wrpc-test` crate.
- the async-task / futures-stream-ABI refactors (bytecodealliance/wit-bindgen#1233/bytecodealliance/wit-bindgen#1241/bytecodealliance/wit-bindgen#1249/bytecodealliance/wit-bindgen#1260/bytecodealliance/wit-bindgen#1264/
  bytecodealliance/wit-bindgen#1268/bytecodealliance/wit-bindgen#1278/bytecodealliance/wit-bindgen#1279/bytecodealliance/wit-bindgen#1247/bytecodealliance/wit-bindgen#1240/bytecodealliance/wit-bindgen#1291/bytecodealliance/wit-bindgen#1306 etc.) and bytecodealliance/wit-bindgen#1214's canonical-ABI
  guest-code warning squashing do not apply to wRPC's transport-stub generator.

rust codegen (237) and go codegen (79) tests pass; `cargo clippy --workspace`
(and `--features serde`) and `cargo doc --workspace` are clean; wasmtime and all
examples build.

Assisted-by: claude:claude-opus-4-8
Upstream diff: bytecodealliance/wit-bindgen@v0.41.0...v0.42.0
psiegl pushed a commit to airbus-forks/wrpc that referenced this pull request Jul 9, 2026
Merge upstream wit-bindgen 0.43.0 into the vendored bindgen subtree.

- Bump wit-bindgen-core 0.42 -> 0.43 and wit-parser 0.230 -> 0.235 (no generator
  API churn this round).
- Carry the new `tests/codegen/async-trait-function.wit` input (an exported
  resource with an `async func` method); wRPC generates it without changes
  (async functions are handled as their sync equivalents over the transport), so
  no skip-arm is needed.

Non-carries (not applicable to wRPC, dropped from the merge):
- another `wit-bindgen test` subcommand backend (`crates/test/src/cpp.rs`).
- the async-ABI / future-stream refactors (bytecodealliance/wit-bindgen#1302/bytecodealliance/wit-bindgen#1315 future/stream ABI and
  names, bytecodealliance/wit-bindgen#1311 async trait function errors, bytecodealliance/wit-bindgen#1306 linear writes) and bytecodealliance/wit-bindgen@504dcd1a
  (disallow 0 in canonical-ABI `from_handle`) do not apply to wRPC's
  transport-stub generator.

rust codegen (240) and go codegen (80) tests pass; `cargo clippy --workspace`
and `cargo doc --workspace` are clean; wasmtime and all examples build.

Assisted-by: claude:claude-opus-4-8
Upstream diff: bytecodealliance/wit-bindgen@v0.42.0...v0.43.0
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.

Ensure FutureWriter always writes

2 participants