-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing examples for using bindgen! async, imports and resource in host #9776
Comments
In general, adding an example of async On the particulars of what the example is doing and whether your given example is best, I don't have super strong opinions. A timer might be smaller and more realistic? Not 100% clear to me. Maybe @alexcrichton has opinions. |
Thanks! Regarding this long function signature, do you know any ways to simplify it? I thought the stabilized async functions in traits might help. I don't know if
|
Definitely feel free to add an example with a PR, it would be most welcome! All of wasmtime's async support was designed before async functions were available in traits, and yes nowadays we should remove the need for If you're up for it a PR to remove |
I will make a PR with a modified example that makes a bit more sense.
So, bindgen indeed uses
We can use #[trait_variant::make(HostLargestring: Send)]
pub trait LocalHostLargestring {
async fn new(&mut self) -> Resource<LargeString>;
// ...
}
Yeah, this may take a while. I will just make a PR to add an example first. Then I will open another tracking issue for this. |
Using |
Feature
There are no examples about using
bindgen!
withasync: true
, imports and resources in Rust hosts. Please add examples to do that.A bit of background
I have a
string.wit
and a guest component.I want to run this component in a Rust host. It took me quite a while to debug and inspect the generated code with
cargo-expand
to implement this. The code is much more complicated than the and there's no way for IDE to help.I didn't have any clues how to write the code until I cargo-expanded the macro.
You should at least add an example in bindgen_example to give a first impression to newcomers about the complexity.
And probably you can simplify the traits of the async version with latest Rust async functions in traits.
Benefit
Pin
andBox
in function signatures, which will enable IDE to autocomplete and help better.Implementation
I can make a PR to submit my code to be an example.
Full Code
The text was updated successfully, but these errors were encountered: