ifsheldon opened issue #9823:
Feature
Remove the use of
async_trait
inbindgen!
as per https://github.com/bytecodealliance/wasmtime/issues/9776#issuecomment-2539971806. Use async fn in traits, RPITIT andtrait_variant
instead.Benefit
Removing
async_trait
simplifies the generated code bybindgen!
a lot. This can also drastically improve IDE experience as IDEs have better support for async fn in traits and RPITIT. Coding experience should be much better as well, as programmers can just useasync fn
when implementing autogenerated traits bybindgen
in async mode.Implementation
Note: I don't have time to dig into details now, so this issue is primary for tracking. Probably someone can tag this as "good first issue" :)
Just search for
::async_trait
in the source code ofwit-bindgen
crate:There are not many occurrences to my surprise.
<img width="620" alt="image" src="https://github.com/user-attachments/assets/f940bf0b-3100-4069-9234-2f619394413a" />
In theory, we need to generate something like:
#[trait_variant::make(HostX: Send)] pub trait LocalHostX { //... }
instead of
#[async_trait] pub trait HostX { //... }
cc @alexcrichton
alexcrichton closed issue #9823:
Feature
Remove the use of
async_trait
inbindgen!
as per https://github.com/bytecodealliance/wasmtime/issues/9776#issuecomment-2539971806. Use async fn in traits, RPITIT andtrait_variant
instead.Benefit
Removing
async_trait
simplifies the generated code bybindgen!
a lot. This can also drastically improve IDE experience as IDEs have better support for async fn in traits and RPITIT. Coding experience should be much better as well, as programmers can just useasync fn
when implementing autogenerated traits bybindgen
in async mode.Implementation
Note: I don't have time to dig into details now, so this issue is primary for tracking. Probably someone can tag this as "good first issue" :)
Just search for
::async_trait
in the source code ofwit-bindgen
crate:There are not many occurrences to my surprise.
<img width="620" alt="image" src="https://github.com/user-attachments/assets/f940bf0b-3100-4069-9234-2f619394413a" />
In theory, we need to generate something like:
#[trait_variant::make(HostX: Send)] pub trait LocalHostX { //... }
instead of
#[async_trait] pub trait HostX { //... }
cc @alexcrichton
Last updated: Dec 23 2024 at 12:05 UTC