Skip to content

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

2.0 KB
Raw Blame
pub mod http;
pub mod sockets;

wit_bindgen::generate!({
    inline: "
        package wasmtime:test;

        world testp3 {
            include wasi:cli/[email protected];
            include wasi:tls/[email protected];
            import wasi:http/[email protected];
            import wasi:http/[email protected];
            import wasi:http/[email protected];

            export wasi:cli/[email protected];
        }
    ",
    path: [
        "../wasi-http/src/p3/wit",
        "../wasi-tls/src/p3/wit",
    ],
    world: "wasmtime:test/testp3",
    default_bindings_module: "test_programs::p3",
    pub_export_macro: true,
    generate_all,
});

pub mod service {
    wit_bindgen::generate!({
        path: "../wasi-http/src/p3/wit",
        world: "wasi:http/service",
        default_bindings_module: "test_programs::p3::service",
        pub_export_macro: true,
        with: {
            "wasi:http/[email protected]": crate::p3::wasi::http::handler,
            "wasi:http/[email protected]": crate::p3::wasi::http::types,
            "wasi:http/[email protected]": crate::p3::wasi::http::client,
            "wasi:random/[email protected]": crate::p3::wasi::random::random,
            "wasi:random/[email protected]": crate::p3::wasi::random::insecure,
            "wasi:random/[email protected]": crate::p3::wasi::random::insecure_seed,
            "wasi:cli/[email protected]": crate::p3::wasi::cli::stdout,
            "wasi:cli/[email protected]": crate::p3::wasi::cli::stderr,
            "wasi:cli/[email protected]": crate::p3::wasi::cli::stdin,
            "wasi:cli/[email protected]": crate::p3::wasi::cli::types,
            "wasi:clocks/[email protected]": crate::p3::wasi::clocks::monotonic_clock,
            "wasi:clocks/[email protected]": crate::p3::wasi::clocks::system_clock,
            "wasi:clocks/[email protected]": crate::p3::wasi::clocks::types,
        },
    });
}

impl std::fmt::Display for wasi::tls::types::Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(&self.to_debug_string())
    }
}

impl std::error::Error for wasi::tls::types::Error {}