Skip to content

Commit 963e579

Browse files
committed
rustfmt
1 parent b2f16b5 commit 963e579

File tree

8 files changed

+19
-24
lines changed

8 files changed

+19
-24
lines changed

crates/test-programs/tests/wasi-http-components-sync.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use wasmtime::{
44
Config, Engine, Store,
55
};
66
use wasmtime_wasi::preview2::{
7-
command::sync::Command, pipe::MemoryOutputPipe, Table, WasiCtx, WasiCtxBuilder,
8-
WasiView,
7+
command::sync::Command, pipe::MemoryOutputPipe, Table, WasiCtx, WasiCtxBuilder, WasiView,
98
};
109
use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView};
1110

crates/test-programs/tests/wasi-http-proxy.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use wasmtime::{
55
Config, Engine, Store,
66
};
77
use wasmtime_wasi::preview2::{
8-
self, pipe::MemoryOutputPipe, IsATTY, Table, WasiCtx, WasiCtxBuilder, WasiView,
8+
self, pipe::MemoryOutputPipe, Table, WasiCtx, WasiCtxBuilder, WasiView,
99
};
1010
use wasmtime_wasi_http::{proxy::Proxy, WasiHttpCtx, WasiHttpView};
1111

@@ -70,17 +70,17 @@ async fn wasi_http_proxy_tests() -> anyhow::Result<()> {
7070
let stdout = MemoryOutputPipe::new(4096);
7171
let stderr = MemoryOutputPipe::new(4096);
7272

73-
let mut table = Table::new();
73+
let table = Table::new();
7474
let component = get_component("wasi_http_proxy_tests");
7575

7676
// Create our wasi context.
7777
let mut builder = WasiCtxBuilder::new();
78-
builder.stdout(stdout.clone(), IsATTY::No);
79-
builder.stderr(stderr.clone(), IsATTY::No);
78+
builder.stdout(stdout.clone());
79+
builder.stderr(stderr.clone());
8080
for (var, val) in test_programs::wasi_tests_environment() {
8181
builder.env(var, val);
8282
}
83-
let wasi = builder.build(&mut table)?;
83+
let wasi = builder.build();
8484
let http = WasiHttpCtx;
8585

8686
let ctx = Ctx { table, wasi, http };

crates/test-programs/wasi-http-proxy-tests/src/lib.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ impl bindings::exports::wasi::http::incoming_handler::Guest for T {
2323

2424
bindings::wasi::http::types::set_response_outparam(outparam, Ok(resp));
2525

26-
let out = bindings::wasi::http::types::outgoing_body_write(body).expect("outgoing stream");
27-
bindings::wasi::io::streams::blocking_write_and_flush(out, b"hello, world!")
26+
let out = body.write().expect("outgoing stream");
27+
out.blocking_write_and_flush(b"hello, world!")
2828
.expect("writing response");
2929

30-
bindings::wasi::io::streams::drop_output_stream(out);
31-
bindings::wasi::http::types::outgoing_body_finish(body, None);
30+
drop(out);
31+
body.finish(None);
3232
}
3333
}

crates/test-programs/wasi-http-tests/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub async fn request(
117117
// TODO: The current implementation requires this drop after the request is sent.
118118
// The ownership semantics are unclear in wasi-http we should clarify exactly what is
119119
// supposed to happen here.
120-
http_types::outgoing_body_finish(outgoing_body, None);
120+
outgoing_body.finish(None);
121121
drop(outgoing_body);
122122

123123
let incoming_response = match http_types::future_incoming_response_get(future_response) {

crates/wasi-http/src/proxy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ wasmtime::component::bindgen!({
2323

2424
pub fn add_to_linker<T>(l: &mut wasmtime::component::Linker<T>) -> anyhow::Result<()>
2525
where
26-
T: WasiHttpView + preview2::WasiView + bindings::http::types::Host,
26+
T: WasiHttpView + preview2::WasiView + bindings::http::types::Host + Sync,
2727
{
2828
// TODO: this shouldn't be required, but the adapter unconditionally pulls in all of these
2929
// dependencies.
@@ -59,7 +59,7 @@ pub mod sync {
5959
},
6060
});
6161

62-
pub fn add_to_linker<T>(l: &mut wasmtime::component::Linker<T>) -> anyhow::Result<()>
62+
pub fn add_to_linker<T: Sync>(l: &mut wasmtime::component::Linker<T>) -> anyhow::Result<()>
6363
where
6464
T: WasiHttpView + preview2::WasiView + bindings::http::types::Host,
6565
{

crates/wasi-http/src/types_impl.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ impl<T: WasiHttpView> crate::bindings::http::types::Host for T {
245245
fn outgoing_request_write(
246246
&mut self,
247247
request: OutgoingRequest,
248-
) -> wasmtime::Result<Result<Resousrce<OutgoingBody>, ()>> {
248+
) -> wasmtime::Result<Result<Resource<OutgoingBody>, ()>> {
249249
let req = types::OutgoingRequestLens::from(request)
250250
.get_mut(self.table())
251251
.context("[outgoing_request_write] getting request")?;
@@ -541,11 +541,7 @@ impl<T: WasiHttpView> crate::bindings::http::types::HostOutgoingBody for T {
541541
}
542542
}
543543

544-
fn outgoing_body_finish(
545-
&mut self,
546-
id: Resource<OutgoingBody>,
547-
ts: Option<Trailers>,
548-
) -> wasmtime::Result<()> {
544+
fn finish(&mut self, id: Resource<OutgoingBody>, ts: Option<Trailers>) -> wasmtime::Result<()> {
549545
let mut body = self.table().delete_outgoing_body(id)?;
550546

551547
let sender = body

crates/wasi-http/wit/deps/http/types.wit

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ interface types {
178178
resource outgoing-body {
179179
/// Will give the child output-stream at most once. subsequent calls will
180180
/// return an error.
181-
write: func(this: /* borrow */ outgoing-body) -> result</* child */ output-stream>
181+
write: func() -> result</* child */ output-stream>
182182
/// Finalize an outgoing body, optionally providing trailers. This must be
183183
/// called to signal that the response is complete. If the `outgoing-body` is
184184
/// dropped without calling `outgoing-body-finalize`, the implementation
185185
/// should treat the body as corrupted.
186-
finish: func(this: /* own */ outgoing-body, trailers: /* own */ option<trailers>)
186+
finish: func(trailers: /* own */ option<trailers>)
187187
}
188188

189189
/// The following block defines a special resource type used by the

crates/wasi/wit/deps/http/types.wit

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,12 @@ interface types {
178178
resource outgoing-body {
179179
/// Will give the child output-stream at most once. subsequent calls will
180180
/// return an error.
181-
write: func(this: /* borrow */ outgoing-body) -> result</* child */ output-stream>
181+
write: func() -> result</* child */ output-stream>
182182
/// Finalize an outgoing body, optionally providing trailers. This must be
183183
/// called to signal that the response is complete. If the `outgoing-body` is
184184
/// dropped without calling `outgoing-body-finalize`, the implementation
185185
/// should treat the body as corrupted.
186-
finish: func(this: /* own */ outgoing-body, trailers: /* own */ option<trailers>)
186+
finish: func(trailers: /* own */ option<trailers>)
187187
}
188188

189189
/// The following block defines a special resource type used by the

0 commit comments

Comments
 (0)