Path: blob/main/crates/test-programs/src/bin/async_round_trip_many_synchronous.rs
1693 views
mod bindings {1wit_bindgen::generate!({2path: "../misc/component-async-tests/wit",3world: "round-trip-many",4async: false,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};46let (a, b, c, d, e, f, g) = many::foo(47&format!("{a} - entered guest"),48b,49&c,50d,51&into(e),52f.map(into).as_ref(),53g.map(into).as_ref().map_err(drop),54);55(56format!("{a} - exited guest",),57b,58c,59d,60from(e),61f.map(from),62g.map(from),63)64}65}6667// Unused function; required since this file is built as a `bin`:68fn main() {}697071