Skip to main content

wasmtime_wasi_http/p2/
bindings.rs

1//! Raw bindings to the `wasi:http` package.
2
3#[expect(missing_docs, reason = "bindgen-generated code")]
4mod generated {
5    use crate::p2::body;
6    use crate::p2::types;
7
8    wasmtime::component::bindgen!({
9        path: "wit",
10        world: "wasi:http/proxy",
11        imports: { default: tracing | trappable },
12        exports: { default: async },
13        require_store_data_send: true,
14        with: {
15            // Upstream package dependencies
16            "wasi:io": wasmtime_wasi::p2::bindings::io,
17
18            // Configure all WIT http resources to be defined types in this
19            // crate to use the `ResourceTable` helper methods.
20            "wasi:http/types.outgoing-body": body::HostOutgoingBody,
21            "wasi:http/types.future-incoming-response": types::HostFutureIncomingResponse,
22            "wasi:http/types.outgoing-response": types::HostOutgoingResponse,
23            "wasi:http/types.future-trailers": body::HostFutureTrailers,
24            "wasi:http/types.incoming-body": body::HostIncomingBody,
25            "wasi:http/types.incoming-response": types::HostIncomingResponse,
26            "wasi:http/types.response-outparam": types::HostResponseOutparam,
27            "wasi:http/types.outgoing-request": types::HostOutgoingRequest,
28            "wasi:http/types.incoming-request": types::HostIncomingRequest,
29            "wasi:http/types.fields": crate::FieldMap,
30            "wasi:http/types.request-options": crate::RequestOptions,
31        },
32        trappable_error_type: {
33            "wasi:http/types.error-code" => crate::p2::HttpError,
34            "wasi:http/types.header-error" => crate::p2::HeaderError,
35        },
36        named_imports: {
37            "wasi:http/outgoing-handler": wasmtime_wasi::NamedId,
38            "wasi:http/types": wasmtime_wasi::NamedId,
39        },
40    });
41}
42
43pub use self::generated::wasi::*;
44
45/// Raw bindings to the `wasi:http/proxy` exports.
46pub use self::generated::exports;
47
48/// Raw bindings to `wasi:http` interfaces when used as named imports.
49pub use self::generated::named_imports;
50
51/// Bindings to the `wasi:http/proxy` world.
52pub use self::generated::{LinkOptions, Proxy, ProxyIndices, ProxyPre};
53
54/// Sync implementation of the `wasi:http/proxy` world.
55pub mod sync {
56    #[expect(missing_docs, reason = "bindgen-generated code")]
57    mod generated {
58        wasmtime::component::bindgen!({
59            world: "wasi:http/proxy",
60            imports: { default: tracing },
61            with: {
62                // http is in this crate
63                "wasi:http": crate::p2::bindings::http,
64                // sync requires the wrapper in the wasmtime_wasi crate, in
65                // order to have in_tokio
66                "wasi:io": wasmtime_wasi::p2::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}