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