Skip to content

Commit

Permalink
Add async example to bindgen_examples (bytecodealliance#9822)
Browse files Browse the repository at this point in the history
* add async example

* fix bindgen bug to make CI happy

See bytecodealliance#9822 (comment)

* update test expectations

* remove async_trait
  • Loading branch information
ifsheldon authored Dec 20, 2024
1 parent 058d751 commit afd8bb3
Show file tree
Hide file tree
Showing 93 changed files with 328 additions and 212 deletions.
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub trait Host {
/// A function that accepts a character
fn take_char(&mut self, x: char) -> ();
Expand Down Expand Up @@ -258,7 +258,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
take_char: wasmtime::component::Func,
return_char: wasmtime::component::Func,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/char_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
pub trait Host: Send {
/// A function that accepts a character
Expand Down Expand Up @@ -274,7 +274,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
take_char: wasmtime::component::Func,
return_char: wasmtime::component::Func,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/char_tracing_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
pub trait Host: Send {
/// A function that accepts a character
Expand Down Expand Up @@ -303,7 +303,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod chars {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
take_char: wasmtime::component::Func,
return_char: wasmtime::component::Func,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/conventions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod conventions {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -420,7 +420,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod conventions {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/conventions_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod conventions {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -456,7 +456,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod conventions {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod conventions {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -616,7 +616,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod conventions {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/dead-code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ pub mod a {
#[allow(clippy::all)]
pub mod interface_with_live_type {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -243,7 +243,7 @@ pub mod a {
#[allow(clippy::all)]
pub mod interface_with_dead_type {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub trait Host {}
pub trait GetHost<
T,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/dead-code_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub mod a {
#[allow(clippy::all)]
pub mod interface_with_live_type {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -257,7 +257,7 @@ pub mod a {
#[allow(clippy::all)]
pub mod interface_with_dead_type {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
pub trait Host: Send {}
pub trait GetHost<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub mod a {
#[allow(clippy::all)]
pub mod interface_with_live_type {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -270,7 +270,7 @@ pub mod a {
#[allow(clippy::all)]
pub mod interface_with_dead_type {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
pub trait Host: Send {}
pub trait GetHost<
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod flegs {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; });
const _: () = {
assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32);
Expand Down Expand Up @@ -446,7 +446,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod flegs {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
wasmtime::component::flags!(
Flag1 { #[component(name = "b0")] const B0; }
);
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/flags_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod flegs {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; });
const _: () = {
assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32);
Expand Down Expand Up @@ -472,7 +472,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod flegs {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
wasmtime::component::flags!(
Flag1 { #[component(name = "b0")] const B0; }
);
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/flags_tracing_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod flegs {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
wasmtime::component::flags!(Flag1 { #[component(name = "b0")] const B0; });
const _: () = {
assert!(1 == < Flag1 as wasmtime::component::ComponentType >::SIZE32);
Expand Down Expand Up @@ -584,7 +584,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod flegs {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
wasmtime::component::flags!(
Flag1 { #[component(name = "b0")] const B0; }
);
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/floats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod floats {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub trait Host {
fn f32_param(&mut self, x: f32) -> ();
fn f64_param(&mut self, x: f64) -> ();
Expand Down Expand Up @@ -275,7 +275,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod floats {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
f32_param: wasmtime::component::Func,
f64_param: wasmtime::component::Func,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/floats_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod floats {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
pub trait Host: Send {
async fn f32_param(&mut self, x: f32) -> ();
Expand Down Expand Up @@ -295,7 +295,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod floats {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
f32_param: wasmtime::component::Func,
f64_param: wasmtime::component::Func,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/floats_tracing_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod floats {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
pub trait Host: Send {
async fn f32_param(&mut self, x: f32) -> ();
Expand Down Expand Up @@ -353,7 +353,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod floats {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
f32_param: wasmtime::component::Func,
f64_param: wasmtime::component::Func,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/integers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod integers {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub trait Host {
fn a1(&mut self, x: u8) -> ();
fn a2(&mut self, x: i8) -> ();
Expand Down Expand Up @@ -485,7 +485,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod integers {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
a1: wasmtime::component::Func,
a2: wasmtime::component::Func,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/integers_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod integers {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
pub trait Host: Send {
async fn a1(&mut self, x: u8) -> ();
Expand Down Expand Up @@ -534,7 +534,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod integers {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
a1: wasmtime::component::Func,
a2: wasmtime::component::Func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod integers {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[wasmtime::component::__internal::trait_variant_make(::core::marker::Send)]
pub trait Host: Send {
async fn a1(&mut self, x: u8) -> ();
Expand Down Expand Up @@ -799,7 +799,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod integers {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
pub struct Guest {
a1: wasmtime::component::Func,
a2: wasmtime::component::Func,
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod lists {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -963,7 +963,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod lists {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/lists_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod lists {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -1073,7 +1073,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod lists {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/lists_tracing_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod lists {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -1504,7 +1504,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod lists {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down
4 changes: 2 additions & 2 deletions crates/component-macro/tests/expanded/many-arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub mod foo {
#[allow(clippy::all)]
pub mod manyarg {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down Expand Up @@ -444,7 +444,7 @@ pub mod exports {
#[allow(clippy::all)]
pub mod manyarg {
#[allow(unused_imports)]
use wasmtime::component::__internal::anyhow;
use wasmtime::component::__internal::{anyhow, Box};
#[derive(wasmtime::component::ComponentType)]
#[derive(wasmtime::component::Lift)]
#[derive(wasmtime::component::Lower)]
Expand Down
Loading

0 comments on commit afd8bb3

Please sign in to comment.