wasmtime_wasi_http/
bindings.rs

1//! Raw bindings to the `wasi:http` package.
2
3#[allow(missing_docs)]
4mod generated {
5    use crate::body;
6    use crate::types;
7
8    wasmtime::component::bindgen!({
9        path: "wit",
10        world: "wasi:http/proxy",
11        tracing: true,
12        // Flag this as "possibly async" which will cause the exports to be
13        // generated as async, but none of the imports here are async since
14        // all the blocking-ness happens in wasi:io
15        async: {
16            only_imports: ["nonexistent"],
17        },
18        trappable_imports: true,
19        require_store_data_send: true,
20        with: {
21            // Upstream package dependencies
22            "wasi:io": wasmtime_wasi::bindings::io,
23
24            // Configure all WIT http resources to be defined types in this
25            // crate to use the `ResourceTable` helper methods.
26            "wasi:http/types/outgoing-body": body::HostOutgoingBody,
27            "wasi:http/types/future-incoming-response": types::HostFutureIncomingResponse,
28            "wasi:http/types/outgoing-response": types::HostOutgoingResponse,
29            "wasi:http/types/future-trailers": body::HostFutureTrailers,
30            "wasi:http/types/incoming-body": body::HostIncomingBody,
31            "wasi:http/types/incoming-response": types::HostIncomingResponse,
32            "wasi:http/types/response-outparam": types::HostResponseOutparam,
33            "wasi:http/types/outgoing-request": types::HostOutgoingRequest,
34            "wasi:http/types/incoming-request": types::HostIncomingRequest,
35            "wasi:http/types/fields": types::HostFields,
36            "wasi:http/types/request-options": types::HostRequestOptions,
37        },
38        trappable_error_type: {
39            "wasi:http/types/error-code" => crate::HttpError,
40        },
41    });
42}
43
44pub use self::generated::wasi::*;
45
46/// Raw bindings to the `wasi:http/proxy` exports.
47pub use self::generated::exports;
48
49/// Bindings to the `wasi:http/proxy` world.
50pub use self::generated::{Proxy, ProxyIndices, ProxyPre};
51
52/// Sync implementation of the `wasi:http/proxy` world.
53pub mod sync {
54    #[allow(missing_docs)]
55    mod generated {
56        #![allow(missing_docs)]
57        wasmtime::component::bindgen!({
58            world: "wasi:http/proxy",
59            tracing: true,
60            async: false,
61            with: {
62                // http is in this crate
63                "wasi:http": crate::bindings::http,
64                // sync requires the wrapper in the wasmtime_wasi crate, in
65                // order to have in_tokio
66                "wasi:io": wasmtime_wasi::bindings::sync::io,
67            },
68            require_store_data_send: true,
69        });
70    }
71
72    pub use self::generated::wasi::*;
73
74    /// Raw bindings to the `wasi:http/proxy` exports.
75    pub use self::generated::exports;
76
77    /// Bindings to the `wasi:http/proxy` world.
78    pub use self::generated::{Proxy, ProxyIndices, ProxyPre};
79}