Skip to content

Commit a6fa3f1

Browse files
authored
Update wit-bindgen, make wasip3 no_std compatible (#153)
* Update wit-bindgen, make `wasip3` no_std compatible This commit updates the `wit-bindgen` crate to 0.57.0 and then additionally updates the `wasip3` crate in the same manner as `wasip2` to make it no_std compatible. This is intended to enable `wasip3` being depended on by the standard library directly. * Fix http-compat build
1 parent 9d39023 commit a6fa3f1

14 files changed

Lines changed: 102 additions & 85 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ jobs:
7575
- run: cargo build --no-default-features -p ${{ matrix.crate }} --target wasm32-wasip1
7676
- run: cargo build --no-default-features -p ${{ matrix.crate }} --target wasm32-wasip2
7777

78+
- run: cargo build --no-default-features -p ${{ matrix.crate }} --features std
79+
- run: cargo build --no-default-features -p ${{ matrix.crate }} --all-features
80+
7881
- run: cargo test -p ${{ matrix.crate }} --doc
7982

8083
generate:
@@ -94,7 +97,7 @@ jobs:
9497
./ci/vendor-wit.sh
9598
git diff --exit-code
9699
- run: |
97-
version=0.54.0
100+
version=0.57.0
98101
99102
mkdir wit-bindgen
100103
cd wit-bindgen

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rust-version = "1.87.0"
2121
[workspace.dependencies]
2222
rand = { version = "0.8.5", default-features = false }
2323
wasi = { version = "0.14.6", path = ".", default-features = false }
24-
wit-bindgen = { version = "0.54.0", default-features = false }
24+
wit-bindgen = { version = "0.57.0", default-features = false }
2525
wasip1 = { version = "1.0.0", path = "crates/wasip1", default-features = false }
2626
wasip2 = { version = "1.0.1", path = "crates/wasip2", default-features = false }
2727
wasip3 = { version = "0.1.1", path = "crates/wasip3", default-features = false }

ci/regenerate.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ generate_p2 crates/wasip2/src/proxy.rs \
100100
# WASIp3 bindings
101101

102102
generate_p3() {
103-
generate "$@" ./crates/wasip3/wit --out-dir crates/wasip3/src
103+
generate "$@" --std-feature ./crates/wasip3/wit --out-dir crates/wasip3/src
104+
105+
sed -z -i 's/#\[unsafe(\n link_section = "\(.*\)"\n)\]/\
106+
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "\1-in-libstd"))]\
107+
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "\1"))]\
108+
/' $file
104109
}
105110

106111
generate_p3 crates/wasip3/src/imports.rs \

crates/wasip2/src/command.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated by `wit-bindgen` 0.54.0. DO NOT EDIT!
1+
// Generated by `wit-bindgen` 0.57.0. DO NOT EDIT!
22
// Options used:
33
// * std_feature
44
// * with "wasi:cli/environment@0.2.9" = "crate::cli::environment"
@@ -167,7 +167,7 @@ macro_rules! __export_command_impl {
167167
exports::wasi::cli::run::__export_wasi_cli_run_0_2_9_cabi!($ty with_types_in
168168
$($path_to_types_root)*:: exports::wasi::cli::run); const _ : () = {
169169
#[rustfmt::skip] #[cfg(target_arch = "wasm32")] #[unsafe (link_section =
170-
"component-type:wit-bindgen:0.54.0:wasi:cli@0.2.9:command:imports and exportsrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-command-world")]
170+
"component-type:wit-bindgen:0.57.0:wasi:cli@0.2.9:command:imports and exportsrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-command-world")]
171171
#[doc(hidden)] #[allow(clippy::octal_escapes)] pub static
172172
__WIT_BINDGEN_COMPONENT_TYPE : [u8; 10773] = *
173173
b"\
@@ -387,8 +387,8 @@ nsecure-random-u64\x01\x02\x03\0\x1awasi:random/insecure@0.2.9\x05*\x01B\x03\x01
387387
o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\0\x1fwasi:random/insecure-\
388388
seed@0.2.9\x05+\x01B\x03\x01j\0\0\x01@\0\0\0\x04\0\x03run\x01\x01\x04\0\x12wasi:\
389389
cli/run@0.2.9\x05,\x04\0\x16wasi:cli/command@0.2.9\x04\0\x0b\x0d\x01\0\x07comman\
390-
d\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.245.1\x10\
391-
wit-bindgen-rust\x060.54.0";
390+
d\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.247.0\x10\
391+
wit-bindgen-rust\x060.57.0";
392392
};
393393
};
394394
}
@@ -397,8 +397,8 @@ pub use __export_command_impl as _export_command;
397397
#[rustfmt::skip]
398398
#[cfg(target_arch = "wasm32")]
399399

400-
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "component-type:wit-bindgen:0.54.0:wasi:cli@0.2.9:command-with-all-of-its-exports-removed:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-command-world-in-libstd"))]
401-
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "component-type:wit-bindgen:0.54.0:wasi:cli@0.2.9:command-with-all-of-its-exports-removed:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-command-world"))]
400+
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "component-type:wit-bindgen:0.57.0:wasi:cli@0.2.9:command-with-all-of-its-exports-removed:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-command-world-in-libstd"))]
401+
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "component-type:wit-bindgen:0.57.0:wasi:cli@0.2.9:command-with-all-of-its-exports-removed:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-command-world"))]
402402

403403
#[doc(hidden)]
404404
#[allow(clippy::octal_escapes)]
@@ -619,7 +619,7 @@ nsecure-random-u64\x01\x02\x03\0\x1awasi:random/insecure@0.2.9\x05*\x01B\x03\x01
619619
o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\0\x1fwasi:random/insecure-\
620620
seed@0.2.9\x05+\x04\06wasi:cli/command-with-all-of-its-exports-removed@0.2.9\x04\
621621
\0\x0b-\x01\0'command-with-all-of-its-exports-removed\x03\0\0\0G\x09producers\x01\
622-
\x0cprocessed-by\x02\x0dwit-component\x070.245.1\x10wit-bindgen-rust\x060.54.0";
622+
\x0cprocessed-by\x02\x0dwit-component\x070.247.0\x10wit-bindgen-rust\x060.57.0";
623623
#[inline(never)]
624624
#[doc(hidden)]
625625
pub fn __link_custom_section_describing_imports() {

crates/wasip2/src/imports.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated by `wit-bindgen` 0.54.0. DO NOT EDIT!
1+
// Generated by `wit-bindgen` 0.57.0. DO NOT EDIT!
22
// Options used:
33
// * std_feature
44
// * type_section_suffix: "rust-wasip2-1.0.2+wasi-0.2.9-from-crates-io"
@@ -9997,8 +9997,8 @@ mod _rt {
99979997
#[rustfmt::skip]
99989998
#[cfg(target_arch = "wasm32")]
99999999

10000-
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "component-type:wit-bindgen:0.54.0:wasi:cli@0.2.9:imports:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-in-libstd"))]
10001-
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "component-type:wit-bindgen:0.54.0:wasi:cli@0.2.9:imports:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io"))]
10000+
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "component-type:wit-bindgen:0.57.0:wasi:cli@0.2.9:imports:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-in-libstd"))]
10001+
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "component-type:wit-bindgen:0.57.0:wasi:cli@0.2.9:imports:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io"))]
1000210002

1000310003
#[doc(hidden)]
1000410004
#[allow(clippy::octal_escapes)]
@@ -10218,8 +10218,8 @@ p}\x01@\x01\x03lenw\0\0\x04\0\x10get-random-bytes\x01\x01\x01@\0\0w\x04\0\x0eget
1021810218
nsecure-random-u64\x01\x02\x03\0\x1awasi:random/insecure@0.2.9\x05*\x01B\x03\x01\
1021910219
o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\0\x1fwasi:random/insecure-\
1022010220
seed@0.2.9\x05+\x04\0\x16wasi:cli/imports@0.2.9\x04\0\x0b\x0d\x01\0\x07imports\x03\
10221-
\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.245.1\x10wit-\
10222-
bindgen-rust\x060.54.0";
10221+
\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.247.0\x10wit-\
10222+
bindgen-rust\x060.57.0";
1022310223
#[inline(never)]
1022410224
#[doc(hidden)]
1022510225
pub fn __link_custom_section_describing_imports() {

crates/wasip2/src/proxy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated by `wit-bindgen` 0.54.0. DO NOT EDIT!
1+
// Generated by `wit-bindgen` 0.57.0. DO NOT EDIT!
22
// Options used:
33
// * std_feature
44
// * with "wasi:cli/stdin@0.2.9" = "crate::cli::stdin"
@@ -7147,7 +7147,7 @@ macro_rules! __export_proxy_impl {
71477147
with_types_in $($path_to_types_root)*:: exports::wasi::http::incoming_handler);
71487148
const _ : () = { #[rustfmt::skip] #[cfg(target_arch = "wasm32")] #[unsafe
71497149
(link_section =
7150-
"component-type:wit-bindgen:0.54.0:wasi:http@0.2.9:proxy:imports and exportsrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-proxy-world")]
7150+
"component-type:wit-bindgen:0.57.0:wasi:http@0.2.9:proxy:imports and exportsrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-proxy-world")]
71517151
#[doc(hidden)] #[allow(clippy::octal_escapes)] pub static
71527152
__WIT_BINDGEN_COMPONENT_TYPE : [u8; 7040] = *
71537153
b"\
@@ -7291,7 +7291,7 @@ incoming-request\x02\x03\0\x09\x11response-outparam\x01B\x08\x02\x03\x02\x01\x14
72917291
m\x03\0\x02\x01i\x01\x01i\x03\x01@\x02\x07request\x04\x0cresponse-out\x05\x01\0\x04\
72927292
\0\x06handle\x01\x06\x04\0\x20wasi:http/incoming-handler@0.2.9\x05\x16\x04\0\x15\
72937293
wasi:http/proxy@0.2.9\x04\0\x0b\x0b\x01\0\x05proxy\x03\0\0\0G\x09producers\x01\x0c\
7294-
processed-by\x02\x0dwit-component\x070.245.1\x10wit-bindgen-rust\x060.54.0";
7294+
processed-by\x02\x0dwit-component\x070.247.0\x10wit-bindgen-rust\x060.57.0";
72957295
};
72967296
};
72977297
}
@@ -7300,8 +7300,8 @@ pub use __export_proxy_impl as _export_proxy;
73007300
#[rustfmt::skip]
73017301
#[cfg(target_arch = "wasm32")]
73027302

7303-
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "component-type:wit-bindgen:0.54.0:wasi:http@0.2.9:proxy-with-all-of-its-exports-removed:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-proxy-world-in-libstd"))]
7304-
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "component-type:wit-bindgen:0.54.0:wasi:http@0.2.9:proxy-with-all-of-its-exports-removed:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-proxy-world"))]
7303+
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "component-type:wit-bindgen:0.57.0:wasi:http@0.2.9:proxy-with-all-of-its-exports-removed:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-proxy-world-in-libstd"))]
7304+
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "component-type:wit-bindgen:0.57.0:wasi:http@0.2.9:proxy-with-all-of-its-exports-removed:encoded worldrust-wasip2-1.0.2+wasi-0.2.9-from-crates-io-proxy-world"))]
73057305

73067306
#[doc(hidden)]
73077307
#[allow(clippy::octal_escapes)]
@@ -7443,7 +7443,7 @@ i\x05\x01j\x01\x0b\x01\x07\x01@\x02\x07request\x08\x07options\x0a\0\x0c\x04\0\x0
74437443
handle\x01\x0d\x03\0\x20wasi:http/outgoing-handler@0.2.9\x05\x13\x04\05wasi:http\
74447444
/proxy-with-all-of-its-exports-removed@0.2.9\x04\0\x0b+\x01\0%proxy-with-all-of-\
74457445
its-exports-removed\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-compo\
7446-
nent\x070.245.1\x10wit-bindgen-rust\x060.54.0";
7446+
nent\x070.247.0\x10wit-bindgen-rust\x060.57.0";
74477447
#[inline(never)]
74487448
#[doc(hidden)]
74497449
pub fn __link_custom_section_describing_imports() {

crates/wasip3/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ rust-version.workspace = true
1515
all-features = true
1616

1717
[features]
18+
default = ["std", "bitflags"]
19+
std = []
20+
bitflags = ["wit-bindgen/bitflags"]
1821
async-spawn = ["wit-bindgen/async-spawn"]
1922
http-compat = [
2023
"dep:bytes",
@@ -25,6 +28,9 @@ http-compat = [
2528
]
2629
wit-bindgen-macros = ["wit-bindgen/macros"]
2730

31+
# Unstable feature to support being a libstd dependency
32+
rustc-dep-of-std = ["core", "alloc", "wit-bindgen/rustc-dep-of-std"]
33+
2834
[dependencies]
2935
# NB: async bindings require `std` right now so this doesn't optionally disable
3036
# `std`, it's intentionally always enabled.
@@ -35,6 +41,10 @@ http-body = { version = "1.0.1", optional = true }
3541
http = { version = "1.3.1", optional = true }
3642
thiserror = { version = "2.0.17", optional = true }
3743

44+
# When built as part of libstd
45+
core = { optional = true, workspace = true }
46+
alloc = { optional = true, workspace = true }
47+
3848
[dev-dependencies]
3949
futures = "0.3.31"
4050
http = "1.3.1"

crates/wasip3/src/command.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// Generated by `wit-bindgen` 0.54.0. DO NOT EDIT!
1+
// Generated by `wit-bindgen` 0.57.0. DO NOT EDIT!
22
// Options used:
3+
// * std_feature
34
// * with "wasi:cli/environment@0.3.0-rc-2026-03-15" = "crate::cli::environment"
45
// * with "wasi:cli/exit@0.3.0-rc-2026-03-15" = "crate::cli::exit"
56
// * with "wasi:cli/stdin@0.3.0-rc-2026-03-15" = "crate::cli::stdin"
@@ -179,7 +180,7 @@ macro_rules! __export_command_impl {
179180
exports::wasi::cli::run::__export_wasi_cli_run_0_3_0_rc_2026_03_15_cabi!($ty
180181
with_types_in $($path_to_types_root)*:: exports::wasi::cli::run); const _ : () =
181182
{ #[rustfmt::skip] #[cfg(target_arch = "wasm32")] #[unsafe (link_section =
182-
"component-type:wit-bindgen:0.54.0:wasi:cli@0.3.0-rc-2026-03-15:command:imports and exportsrust-wasip3-0.5.0+wasi-0.3.0-rc-2026-03-15-from-crates-io-command-world")]
183+
"component-type:wit-bindgen:0.57.0:wasi:cli@0.3.0-rc-2026-03-15:command:imports and exportsrust-wasip3-0.5.0+wasi-0.3.0-rc-2026-03-15-from-crates-io-command-world")]
183184
#[doc(hidden)] #[allow(clippy::octal_escapes)] pub static
184185
__WIT_BINDGEN_COMPONENT_TYPE : [u8; 8219] = *
185186
b"\
@@ -341,18 +342,19 @@ p}\x01@\x01\x07max-lenw\0\0\x04\0\x19get-insecure-random-bytes\x01\x01\x01@\0\0w
341342
\x03\0-wasi:random/insecure-seed@0.3.0-rc-2026-03-15\x05\x1b\x01B\x03\x01j\0\0\x01\
342343
C\0\0\0\x04\0\x03run\x01\x01\x04\0\x20wasi:cli/run@0.3.0-rc-2026-03-15\x05\x1c\x04\
343344
\0$wasi:cli/command@0.3.0-rc-2026-03-15\x04\0\x0b\x0d\x01\0\x07command\x03\0\0\0\
344-
G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.245.1\x10wit-bindge\
345-
n-rust\x060.54.0";
345+
G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.247.0\x10wit-bindge\
346+
n-rust\x060.57.0";
346347
};
347348
};
348349
}
349350
#[doc(inline)]
350351
pub use __export_command_impl as _export_command;
351352
#[rustfmt::skip]
352353
#[cfg(target_arch = "wasm32")]
353-
#[unsafe(
354-
link_section = "component-type:wit-bindgen:0.54.0:wasi:cli@0.3.0-rc-2026-03-15:command-with-all-of-its-exports-removed:encoded worldrust-wasip3-0.5.0+wasi-0.3.0-rc-2026-03-15-from-crates-io-command-world"
355-
)]
354+
355+
#[cfg_attr(feature = "rustc-dep-of-std", unsafe(link_section = "component-type:wit-bindgen:0.57.0:wasi:cli@0.3.0-rc-2026-03-15:command-with-all-of-its-exports-removed:encoded worldrust-wasip3-0.5.0+wasi-0.3.0-rc-2026-03-15-from-crates-io-command-world-in-libstd"))]
356+
#[cfg_attr(not(feature = "rustc-dep-of-std"), unsafe(link_section = "component-type:wit-bindgen:0.57.0:wasi:cli@0.3.0-rc-2026-03-15:command-with-all-of-its-exports-removed:encoded worldrust-wasip3-0.5.0+wasi-0.3.0-rc-2026-03-15-from-crates-io-command-world"))]
357+
356358
#[doc(hidden)]
357359
#[allow(clippy::octal_escapes)]
358360
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 8226] = *b"\
@@ -514,7 +516,7 @@ p}\x01@\x01\x07max-lenw\0\0\x04\0\x19get-insecure-random-bytes\x01\x01\x01@\0\0w
514516
\x03\0-wasi:random/insecure-seed@0.3.0-rc-2026-03-15\x05\x1b\x04\0Dwasi:cli/comm\
515517
and-with-all-of-its-exports-removed@0.3.0-rc-2026-03-15\x04\0\x0b-\x01\0'command\
516518
-with-all-of-its-exports-removed\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\
517-
\x0dwit-component\x070.245.1\x10wit-bindgen-rust\x060.54.0";
519+
\x0dwit-component\x070.247.0\x10wit-bindgen-rust\x060.57.0";
518520
#[inline(never)]
519521
#[doc(hidden)]
520522
pub fn __link_custom_section_describing_imports() {

crates/wasip3/src/http_compat/body_writer.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{
66
use http::HeaderMap;
77
use http_body::{Body as _, Frame};
88
use std::future::poll_fn;
9+
use std::prelude::v1::*;
910
use std::{fmt::Debug, pin};
1011

1112
type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;

crates/wasip3/src/http_compat/conversions.rs

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
11
use super::{
2-
to_internal_error_code,
3-
RequestOptionsExtension,
4-
IncomingRequestBody,
5-
IncomingResponseBody,
6-
Request as HttpRequest,
7-
Response as HttpResponse,
8-
body_writer::BodyWriter,
2+
body_writer::BodyWriter, to_internal_error_code, IncomingRequestBody, IncomingResponseBody,
3+
Request as HttpRequest, RequestOptionsExtension, Response as HttpResponse,
94
};
105
use crate::http::types::{
11-
ErrorCode,
12-
Fields,
13-
HeaderError,
14-
Headers,
15-
Method,
16-
Scheme,
17-
Request as WasiHttpRequest,
18-
Response as WasiHttpResponse,
19-
};
20-
use std::{
21-
any::Any,
22-
convert::TryFrom,
6+
ErrorCode, Fields, HeaderError, Headers, Method, Request as WasiHttpRequest,
7+
Response as WasiHttpResponse, Scheme,
238
};
9+
use std::prelude::v1::*;
10+
use std::{any::Any, convert::TryFrom};
2411

2512
/// Converts a host-side HTTP response (`HttpResponse<T>`) into a WASI HTTP response (`WasiHttpResponse`).
2613
///
2714
/// This function bridges standard Rust `http` responses with the WASI HTTP model,
2815
/// serializing status codes, headers, and body data into their WebAssembly-compatible
2916
/// representations. It supports generic response body types and streams the response
3017
/// asynchronously into the WASI environment.
31-
///
18+
///
3219
/// # See Also
3320
///
3421
/// - [`http_from_wasi_response`] — converts a WASI response back into a host-side HTTP response.
@@ -38,7 +25,7 @@ pub fn http_into_wasi_response<T>(mut resp: HttpResponse<T>) -> Result<WasiHttpR
3825
where
3926
T: http_body::Body + Any,
4027
T::Data: Into<Vec<u8>>,
41-
T::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>
28+
T::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
4229
{
4330
if let Some(incoming_body) = (&mut resp as &mut dyn Any).downcast_mut::<IncomingResponseBody>()
4431
{
@@ -55,8 +42,7 @@ where
5542

5643
let (body_writer, body_rx, body_result_rx) = BodyWriter::new();
5744

58-
let (response, _future_result) =
59-
WasiHttpResponse::new(headers, Some(body_rx), body_result_rx);
45+
let (response, _future_result) = WasiHttpResponse::new(headers, Some(body_rx), body_result_rx);
6046

6147
_ = response.set_status_code(resp.status().as_u16());
6248

@@ -74,7 +60,7 @@ where
7460
/// This function performs the reverse operation of [`http_into_wasi_response`], translating
7561
/// the fields and body of a response from the WASI HTTP model into the conventional Rust
7662
/// `http` crate representation.
77-
///
63+
///
7864
/// # See Also
7965
///
8066
/// - [`http_into_wasi_response`] — the inverse conversion.
@@ -107,10 +93,9 @@ pub fn http_into_wasi_request<T>(mut req: HttpRequest<T>) -> Result<WasiHttpRequ
10793
where
10894
T: http_body::Body + Any,
10995
T::Data: Into<Vec<u8>>,
110-
T::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>
96+
T::Error: Into<Box<dyn std::error::Error + Send + Sync + 'static>>,
11197
{
112-
if let Some(incoming_body) = (&mut req as &mut dyn Any).downcast_mut::<IncomingRequestBody>()
113-
{
98+
if let Some(incoming_body) = (&mut req as &mut dyn Any).downcast_mut::<IncomingRequestBody>() {
11499
if let Some(request) = incoming_body.take_unstarted() {
115100
return Ok(request);
116101
}
@@ -124,10 +109,7 @@ where
124109
.cloned()
125110
.map(|o| o.0);
126111

127-
let headers = parts
128-
.headers
129-
.try_into()
130-
.map_err(to_internal_error_code)?;
112+
let headers = parts.headers.try_into().map_err(to_internal_error_code)?;
131113

132114
let (body_writer, contents_rx, trailers_rx) = BodyWriter::new();
133115

@@ -161,7 +143,7 @@ where
161143
/// from the WASI HTTP model into a conventional Rust `http` request type. It reconstructs
162144
/// the URI, method, headers, extensions, and body so that the request can be used directly
163145
/// by host HTTP clients, servers, or middleware.
164-
///
146+
///
165147
/// # See Also
166148
///
167149
/// - [`http_into_wasi_request`] — converts from host HTTP requests into WASI requests.
@@ -185,9 +167,7 @@ pub fn http_from_wasi_request(req: WasiHttpRequest) -> Result<HttpRequest, Error
185167
.map_err(|_| ErrorCode::HttpRequestUriInvalid)?
186168
};
187169

188-
let mut builder = http::Request::builder()
189-
.method(req.get_method())
190-
.uri(uri);
170+
let mut builder = http::Request::builder().method(req.get_method()).uri(uri);
191171

192172
if let Some(options) = req.get_options().map(RequestOptionsExtension) {
193173
builder = builder.extension(options);

0 commit comments

Comments
 (0)