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