Path: blob/main/crates/test-programs/src/bin/async_round_trip_many_wait.rs
1693 views
mod bindings {1wit_bindgen::generate!({2path: "../misc/component-async-tests/wit",3world: "round-trip-many",4async: ["-export:local:local/many#[async]foo"],5});67use super::Component;8export!(Component);9}1011use bindings::{12exports::local::local::many::{Guest, Stuff},13local::local::many,14};1516struct Component;1718impl Guest for Component {19fn foo(20a: String,21b: u32,22c: Vec<u8>,23d: (u64, u64),24e: Stuff,25f: Option<Stuff>,26g: Result<Stuff, ()>,27) -> (28String,29u32,30Vec<u8>,31(u64, u64),32Stuff,33Option<Stuff>,34Result<Stuff, ()>,35) {36let into = |v: Stuff| many::Stuff {37a: v.a,38b: v.b,39c: v.c,40};41let from = |v: many::Stuff| Stuff {42a: v.a,43b: v.b,44c: v.c,45};46wit_bindgen::block_on(async move {47let (a, b, c, d, e, f, g) = many::foo(48format!("{a} - entered guest"),49b,50c,51d,52into(e),53f.map(into),54g.map(into).map_err(drop),55)56.await;57(58format!("{a} - exited guest",),59b,60c,61d,62from(e),63f.map(from),64g.map(from),65)66})67}68}6970// Unused function; required since this file is built as a `bin`:71fn main() {}727374