Stream: wit-bindgen

Topic: `Send` for generated async wrappers?


view this post on Zulip Jelle van den Hooff (Oct 23 2025 at 21:59):

Hi, I am trying to use some of the new async support to expose a sqlite interface to a rust wasm app. The async support is, overall, amazing! However, I am running into problems because the wit-bindgen generated wrappers are not Send, as their futures store some *mut u8 internally. That is an issue because Axum, which I am using to do some HTTP routing, has a Handler trait which requires Send.

I can work around this by doing the call to the generated wrapper inside of a wit_bindgen::spawn and then sending the result back over a oneshot channel but that's yucky. I am sure I do not appreciate the subtleties of this, but I am currently thinking that since components are currently single-threaded, marking everything as Send might be okay, and that would require some wrapper type around the *mut u8 marked as Send.

Curious to hear thoughts and suggestions. Thanks

view this post on Zulip Alex Crichton (Oct 23 2025 at 22:42):

Oh this is definitely a bug and we should be able to mark things as Send, if you're up for it I'm happy to review a PR to the generated bindings to ensure this

view this post on Zulip Jelle van den Hooff (Oct 24 2025 at 02:24):

Great, thanks, I will see if I can get my head around the codegen :)

view this post on Zulip Jelle van den Hooff (Oct 24 2025 at 18:10):

I submitted https://github.com/bytecodealliance/wit-bindgen/pull/1405. Feedback on style and substance very welcome

The futures for generated rust async bindings were not always Send, because the LoweredParams held a non-Send *mut u8. To fix this, explicitly implement Send for LoweredParams. This makes the futur...

Last updated: Dec 06 2025 at 07:03 UTC