Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

1.2 KB
Raw Blame
use super::Ctx;
use crate::util::yield_times;
use wasmtime::Result;
use wasmtime::component::Accessor;

pub mod bindings {
    wasmtime::component::bindgen!({
        path: "wit",
        world: "round-trip-many",
        additional_derives: [ Eq, PartialEq ],
    });
}

pub mod non_concurrent_export_bindings {
    wasmtime::component::bindgen!({
        path: "wit",
        world: "round-trip-many",
        additional_derives: [ Eq, PartialEq ],
        exports: { default: async },
    });
}

use bindings::local::local::many::Stuff;

impl<T> bindings::local::local::many::HostWithStore<T> for Ctx {
    async fn foo(
        _: &Accessor<T, Self>,
        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, ()>,
    ) {
        yield_times(5).await;
        (
            format!("{a} - entered host - exited host"),
            b,
            c,
            d,
            e,
            f,
            g,
        )
    }
}

impl bindings::local::local::many::Host for Ctx {}