wasmtime_wasi_http/
bindings.rs

1//! Raw bindings to the `wasi:http` package.
2
3#[expect(missing_docs, reason = "bindgen-generated code")]
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::p2::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    #[expect(missing_docs, reason = "bindgen-generated code")]
55    mod generated {
56        wasmtime::component::bindgen!({
57            world: "wasi:http/proxy",
58            tracing: true,
59            async: false,
60            with: {
61                // http is in this crate
62                "wasi:http": crate::bindings::http,
63                // sync requires the wrapper in the wasmtime_wasi crate, in
64                // order to have in_tokio
65                "wasi:io": wasmtime_wasi::p2::bindings::sync::io,
66            },
67            require_store_data_send: true,
68        });
69    }
70
71    pub use self::generated::wasi::*;
72
73    /// Raw bindings to the `wasi:http/proxy` exports.
74    pub use self::generated::exports;
75
76    /// Bindings to the `wasi:http/proxy` world.
77    pub use self::generated::{Proxy, ProxyIndices, ProxyPre};
78}