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