Skip to content

Conversation

@dicej
Copy link
Collaborator

@dicej dicej commented Nov 4, 2025

This does two things:

First, it adds a low-level API to wit-dylib-ffi for async imports and exports as an alternative to the high-level API based on wit-bindgen's rt library and enabled with the async feature. Thus enabling the async feature now really just means "use the high-level API", while disabling it means "use the low-level API". The low-level API can make more sense for e.g. Python, where the coroutine model is different enough from Rust's that it's easier to map it directly to the component model ABI rather than try to plumb it through Rust's async APIs.

Second, it populates the wit_future and wit_stream types with all the relevant intrinsics, ABI size/align metadata, and generated payload lift and lower functions.

I've tested this all end-to-end with componentize-py, but could use some guidance on how to add tests here as well.

@dicej dicej requested a review from a team as a code owner November 4, 2025 22:39
@dicej dicej requested review from alexcrichton and fitzgen and removed request for a team November 4, 2025 22:39
This does two things:

First, it adds a low-level API to `wit-dylib-ffi` for async imports and exports
as an alternative to the high-level API based on `wit-bindgen`'s `rt` library
and enabled with the `async` feature.  Thus enabling the `async` feature now
really just means "use the high-level API", while disabling it means "use the
low-level API".  The low-level API can make more sense for e.g. Python, where
the coroutine model is different enough from Rust's that it's easier to map it
directly to the component model ABI rather than try to plumb it through Rust's
async APIs.

Second, it populates the `wit_future` and `wit_stream` types with all the
relevant intrinsics, ABI size/align metadata, and generated payload lift and
lower functions.

I've tested this all end-to-end with `componentize-py`, but could use some
guidance on how to add tests here as well.

Signed-off-by: Joel Dice <[email protected]>
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Mind adding some simple tests here too?

- `async-runtime`: integrates with `std::future` by way of `wit_bindgen::rt`
- `async-raw`: minimal layer over raw bindings; does not use `std::future` or `wit_bindgen`

Note that these are mutually exclusive; enabling both will result in a compiler
error.

Signed-off-by: Joel Dice <[email protected]>
...and add a comment explaining why it's still needed in `lower_payload`.

Signed-off-by: Joel Dice <[email protected]>
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.

2 participants