Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/crates/misc/component-async-tests/src/round_trip_many.rs
1692 views
1
use super::Ctx;
2
use anyhow::Result;
3
use std::time::Duration;
4
use wasmtime::component::Accessor;
5
6
pub mod bindings {
7
wasmtime::component::bindgen!({
8
path: "wit",
9
world: "round-trip-many",
10
additional_derives: [ Eq, PartialEq ],
11
});
12
}
13
14
pub mod non_concurrent_export_bindings {
15
wasmtime::component::bindgen!({
16
path: "wit",
17
world: "round-trip-many",
18
additional_derives: [ Eq, PartialEq ],
19
exports: { default: ignore_wit | async },
20
});
21
}
22
23
use bindings::local::local::many::Stuff;
24
25
impl bindings::local::local::many::HostWithStore for Ctx {
26
async fn foo<T>(
27
_: &Accessor<T, Self>,
28
a: String,
29
b: u32,
30
c: Vec<u8>,
31
d: (u64, u64),
32
e: Stuff,
33
f: Option<Stuff>,
34
g: Result<Stuff, ()>,
35
) -> (
36
String,
37
u32,
38
Vec<u8>,
39
(u64, u64),
40
Stuff,
41
Option<Stuff>,
42
Result<Stuff, ()>,
43
) {
44
crate::util::sleep(Duration::from_millis(10)).await;
45
(
46
format!("{a} - entered host - exited host"),
47
b,
48
c,
49
d,
50
e,
51
f,
52
g,
53
)
54
}
55
}
56
57
impl bindings::local::local::many::Host for Ctx {}
58
59