Skip to content

Commit

Permalink
WASI wits: use 0.2.0-rc-2023-11-10 (bytecodealliance#7533)
Browse files Browse the repository at this point in the history
* wit deps: use 0.2.0-rc-2023-11-10 from WebAssembly/wasi-* repos

* local wits: depend on rc-2023-11-10

* wit-bindgen invocation: use rc-2023-11-10

* wasi-http wit subdir: sync with wasi

* wasi-http wit-bindgen: update for 11-10 rc

* wasi-preview1-component-adapter: imports are from 11-10 rc

* cli test component-basic: use wasi rc 11-10
  • Loading branch information
Pat Hickey authored and alexcrichton committed Nov 14, 2023
1 parent b47fc15 commit 1e3155d
Show file tree
Hide file tree
Showing 56 changed files with 251 additions and 145 deletions.
6 changes: 3 additions & 3 deletions crates/wasi-http/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ pub mod bindings {
wasmtime::component::bindgen!({
path: "wit",
interfaces: "
import wasi:http/[email protected]05;
import wasi:http/[email protected]05;
import wasi:http/[email protected]05;
import wasi:http/[email protected]10;
import wasi:http/[email protected]10;
import wasi:http/[email protected]10;
",
tracing: true,
async: false,
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/src/types_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use wasmtime_wasi::preview2::{
impl<T: WasiHttpView> crate::bindings::http::types::Host for T {
fn http_error_code(
&mut self,
_err: wasmtime::component::Resource<types::StreamError>,
_err: wasmtime::component::Resource<types::IoError>,
) -> wasmtime::Result<Option<types::ErrorCode>> {
todo!()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/wasi-http/wit/command-extended.wit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// All of the same imports and exports available in the wasi:cli/command world
// with addition of HTTP proxy related imports:
world command-extended {
include wasi:cli/command@0.2.0-rc-2023-11-05;
import wasi:http/outgoing-handler@0.2.0-rc-2023-11-05;
include wasi:cli/command@0.2.0-rc-2023-11-10;
import wasi:http/outgoing-handler@0.2.0-rc-2023-11-10;
}
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/cli/command.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:cli@0.2.0-rc-2023-11-05;
package wasi:cli@0.2.0-rc-2023-11-10;

world command {
include reactor;
Expand Down
34 changes: 17 additions & 17 deletions crates/wasi-http/wit/deps/cli/reactor.wit
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package wasi:cli@0.2.0-rc-2023-11-05;
package wasi:cli@0.2.0-rc-2023-11-10;

world reactor {
import wasi:clocks/wall-clock@0.2.0-rc-2023-11-05;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05;
import wasi:filesystem/types@0.2.0-rc-2023-11-05;
import wasi:filesystem/preopens@0.2.0-rc-2023-11-05;
import wasi:sockets/instance-network@0.2.0-rc-2023-11-05;
import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-05;
import wasi:sockets/network@0.2.0-rc-2023-11-05;
import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-05;
import wasi:sockets/tcp@0.2.0-rc-2023-11-05;
import wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-05;
import wasi:sockets/udp@0.2.0-rc-2023-11-05;
import wasi:random/random@0.2.0-rc-2023-11-05;
import wasi:random/insecure@0.2.0-rc-2023-11-05;
import wasi:random/insecure-seed@0.2.0-rc-2023-11-05;
import wasi:io/poll@0.2.0-rc-2023-11-05;
import wasi:io/streams@0.2.0-rc-2023-11-05;
import wasi:clocks/wall-clock@0.2.0-rc-2023-11-10;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10;
import wasi:filesystem/types@0.2.0-rc-2023-11-10;
import wasi:filesystem/preopens@0.2.0-rc-2023-11-10;
import wasi:sockets/instance-network@0.2.0-rc-2023-11-10;
import wasi:sockets/ip-name-lookup@0.2.0-rc-2023-11-10;
import wasi:sockets/network@0.2.0-rc-2023-11-10;
import wasi:sockets/tcp-create-socket@0.2.0-rc-2023-11-10;
import wasi:sockets/tcp@0.2.0-rc-2023-11-10;
import wasi:sockets/udp-create-socket@0.2.0-rc-2023-11-10;
import wasi:sockets/udp@0.2.0-rc-2023-11-10;
import wasi:random/random@0.2.0-rc-2023-11-10;
import wasi:random/insecure@0.2.0-rc-2023-11-10;
import wasi:random/insecure-seed@0.2.0-rc-2023-11-10;
import wasi:io/poll@0.2.0-rc-2023-11-10;
import wasi:io/streams@0.2.0-rc-2023-11-10;

import environment;
import exit;
Expand Down
6 changes: 3 additions & 3 deletions crates/wasi-http/wit/deps/cli/stdio.wit
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
interface stdin {
use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream};
use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream};

get-stdin: func() -> input-stream;
}

interface stdout {
use wasi:io/streams@0.2.0-rc-2023-11-05.{output-stream};
use wasi:io/streams@0.2.0-rc-2023-11-10.{output-stream};

get-stdout: func() -> output-stream;
}

interface stderr {
use wasi:io/streams@0.2.0-rc-2023-11-05.{output-stream};
use wasi:io/streams@0.2.0-rc-2023-11-10.{output-stream};

get-stderr: func() -> output-stream;
}
3 changes: 2 additions & 1 deletion crates/wasi-http/wit/deps/clocks/monotonic-clock.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package wasi:clocks@0.2.0-rc-2023-11-10;
/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
/// time.
///
Expand All @@ -9,7 +10,7 @@
///
/// It is intended for measuring elapsed time.
interface monotonic-clock {
use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable};

/// An instant in time, in nanoseconds. An instant is relative to an
/// unspecified initial value, and can only be compared to instances from
Expand Down
1 change: 1 addition & 0 deletions crates/wasi-http/wit/deps/clocks/wall-clock.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package wasi:clocks@0.2.0-rc-2023-11-10;
/// WASI Wall Clock is a clock API intended to let users query the current
/// time. The name "wall" makes an analogy to a "clock on the wall", which
/// is not necessarily monotonic as it may be reset.
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/clocks/world.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:clocks@0.2.0-rc-2023-11-05;
package wasi:clocks@0.2.0-rc-2023-11-10;

world imports {
import monotonic-clock;
Expand Down
2 changes: 2 additions & 0 deletions crates/wasi-http/wit/deps/filesystem/preopens.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package wasi:filesystem@0.2.0-rc-2023-11-10;

interface preopens {
use types.{descriptor};

Expand Down
5 changes: 3 additions & 2 deletions crates/wasi-http/wit/deps/filesystem/types.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package wasi:filesystem@0.2.0-rc-2023-11-10;
/// WASI filesystem is a filesystem API primarily intended to let users run WASI
/// programs that access their files on their existing filesystems, without
/// significant overhead.
Expand All @@ -23,8 +24,8 @@
///
/// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md
interface types {
use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream, output-stream, error};
use wasi:clocks/wall-clock@0.2.0-rc-2023-11-05.{datetime};
use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream, output-stream, error};
use wasi:clocks/wall-clock@0.2.0-rc-2023-11-10.{datetime};

/// File size or length of a region within a file.
type filesize = u64;
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/filesystem/world.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:filesystem@0.2.0-rc-2023-11-05;
package wasi:filesystem@0.2.0-rc-2023-11-10;

world imports {
import types;
Expand Down
14 changes: 7 additions & 7 deletions crates/wasi-http/wit/deps/http/proxy.wit
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package wasi:http@0.2.0-rc-2023-11-05;
package wasi:http@0.2.0-rc-2023-11-10;

/// The `wasi:http/proxy` world captures a widely-implementable intersection of
/// hosts that includes HTTP forward and reverse proxies. Components targeting
/// this world may concurrently stream in and out any number of incoming and
/// outgoing HTTP requests.
world proxy {
/// HTTP proxies have access to time and randomness.
import wasi:clocks/wall-clock@0.2.0-rc-2023-11-05;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05;
import wasi:random/random@0.2.0-rc-2023-11-05;
import wasi:clocks/wall-clock@0.2.0-rc-2023-11-10;
import wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10;
import wasi:random/random@0.2.0-rc-2023-11-10;

/// Proxies have standard output and error streams which are expected to
/// terminate in a developer-facing console provided by the host.
import wasi:cli/stdout@0.2.0-rc-2023-11-05;
import wasi:cli/stderr@0.2.0-rc-2023-11-05;
import wasi:cli/stdout@0.2.0-rc-2023-11-10;
import wasi:cli/stderr@0.2.0-rc-2023-11-10;

/// TODO: this is a temporary workaround until component tooling is able to
/// gracefully handle the absence of stdin. Hosts must return an eof stream
/// for this import, which is what wasi-libc + tooling will do automatically
/// when this import is properly removed.
import wasi:cli/stdin@0.2.0-rc-2023-11-05;
import wasi:cli/stdin@0.2.0-rc-2023-11-10;

/// This is the default handler to use when user code simply wants to make an
/// HTTP request (e.g., via `fetch()`).
Expand Down
73 changes: 59 additions & 14 deletions crates/wasi-http/wit/deps/http/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
/// HTTP Requests and Responses, both incoming and outgoing, as well as
/// their headers, trailers, and bodies.
interface types {
use wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-05.{duration};
use wasi:io/streams@0.2.0-rc-2023-11-05.{input-stream, output-stream, error as stream-error};
use wasi:io/poll@0.2.0-rc-2023-11-05.{pollable};
use wasi:clocks/monotonic-clock@0.2.0-rc-2023-11-10.{duration};
use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream, output-stream};
use wasi:io/error@0.2.0-rc-2023-11-10.{error as io-error};
use wasi:io/poll@0.2.0-rc-2023-11-10.{pollable};

/// This type corresponds to HTTP standard Methods.
variant method {
Expand Down Expand Up @@ -94,17 +95,18 @@ interface types {
field-size: option<u32>
}

/// Attempts to extract a http-related `error` from the stream `error`
/// Attempts to extract a http-related `error` from the wasi:io `error`
/// provided.
///
/// Stream operations which return `stream-error::last-operation-failed` have
/// a payload with more information about the operation that failed. This
/// payload can be passed through to this function to see if there's
/// http-related information about the error to return.
/// Stream operations which return
/// `wasi:io/stream/stream-error::last-operation-failed` have a payload of
/// type `wasi:io/error/error` with more information about the operation
/// that failed. This payload can be passed through to this function to see
/// if there's http-related information about the error to return.
///
/// Note that this function is fallible because not all stream-related errors
/// are http-related errors.
http-error-code: func(err: borrow<stream-error>) -> option<error-code>;
/// Note that this function is fallible because not all io-errors are
/// http-related errors.
http-error-code: func(err: borrow<io-error>) -> option<error-code>;

/// This type enumerates the different kinds of errors that may occur when
/// setting or appending to a `fields` resource.
Expand Down Expand Up @@ -134,13 +136,24 @@ interface types {
/// This following block defines the `fields` resource which corresponds to
/// HTTP standard Fields. Fields are a common representation used for both
/// Headers and Trailers.
///
/// A `fields` may be mutable or immutable. A `fields` created using the
/// constructor, `from-list`, or `clone` will be mutable, but a `fields`
/// resource given by other means (including, but not limited to,
/// `incoming-request.headers`, `outgoing-request.headers`) might be be
/// immutable. In an immutable fields, the `set`, `append`, and `delete`
/// operations will fail with `header-error.immutable`.
resource fields {

/// Construct an empty HTTP Fields.
///
/// The resulting `fields` is mutable.
constructor();

/// Construct an HTTP Fields.
///
/// The resulting `fields` is mutable.
///
/// The list represents each key-value pair in the Fields. Keys
/// which have multiple values are represented by multiple entries in this
/// list with the same key.
Expand All @@ -161,14 +174,20 @@ interface types {

/// Set all of the values for a key. Clears any existing values for that
/// key, if they have been set.
///
/// Fails with `header-error.immutable` if the `fields` are immutable.
set: func(name: field-key, value: list<field-value>) -> result<_, header-error>;

/// Delete all values for a key. Does nothing if no values for the key
/// exist.
///
/// Fails with `header-error.immutable` if the `fields` are immutable.
delete: func(name: field-key) -> result<_, header-error>;

/// Append a value for a key. Does not change or delete any existing
/// values for that key.
///
/// Fails with `header-error.immutable` if the `fields` are immutable.
append: func(name: field-key, value: field-value) -> result<_, header-error>;

/// Retrieve the full set of keys and values in the Fields. Like the
Expand All @@ -180,7 +199,8 @@ interface types {
entries: func() -> list<tuple<field-key,field-value>>;

/// Make a deep copy of the Fields. Equivelant in behavior to calling the
/// `fields` constructor on the return value of `entries`
/// `fields` constructor on the return value of `entries`. The resulting
/// `fields` is mutable.
clone: func() -> fields;
}

Expand All @@ -205,7 +225,10 @@ interface types {
/// Returns the authority from the request, if it was present.
authority: func() -> option<string>;

/// Returns the `headers` from the request.
/// Get the `headers` associated with the request.
///
/// The returned `headers` resource is immutable: `set`, `append`, and
/// `delete` operations will fail with `header-error.immutable`.
///
/// The `headers` returned are a child resource: it must be dropped before
/// the parent `incoming-request` is dropped. Dropping this
Expand Down Expand Up @@ -238,7 +261,7 @@ interface types {
/// Request.
///
/// Returns success on the first call: the `outgoing-body` resource for
/// this `outgoing-response` can be retrieved at most once. Subsequent
/// this `outgoing-request` can be retrieved at most once. Subsequent
/// calls will return error.
body: func() -> result<outgoing-body>;

Expand Down Expand Up @@ -276,6 +299,9 @@ interface types {

/// Get the headers associated with the Request.
///
/// The returned `headers` resource is immutable: `set`, `append`, and
/// `delete` operations will fail with `header-error.immutable`.
///
/// This headers resource is a child: it must be dropped before the parent
/// `outgoing-request` is dropped, or its ownership is transfered to
/// another component by e.g. `outgoing-handler.handle`.
Expand Down Expand Up @@ -348,6 +374,12 @@ interface types {
status: func() -> status-code;

/// Returns the headers from the incoming response.
///
/// The returned `headers` resource is immutable: `set`, `append`, and
/// `delete` operations will fail with `header-error.immutable`.
///
/// This headers resource is a child: it must be dropped before the parent
/// `incoming-response` is dropped.
headers: func() -> headers;

/// Returns the incoming body. May be called at most once. Returns error
Expand Down Expand Up @@ -409,6 +441,11 @@ interface types {
/// as well as any trailers, were received successfully, or that an error
/// occured receiving them. The optional `trailers` indicates whether or not
/// trailers were present in the body.
///
/// When some `trailers` are returned by this method, the `trailers`
/// resource is immutable, and a child. Use of the `set`, `append`, or
/// `delete` methods will return an error, and the resource must be
/// dropped before the parent `future-trailers` is dropped.
get: func() -> option<result<option<trailers>, error-code>>;
}

Expand All @@ -431,6 +468,9 @@ interface types {

/// Get the headers associated with the Request.
///
/// The returned `headers` resource is immutable: `set`, `append`, and
/// `delete` operations will fail with `header-error.immutable`.
///
/// This headers resource is a child: it must be dropped before the parent
/// `outgoing-request` is dropped, or its ownership is transfered to
/// another component by e.g. `outgoing-handler.handle`.
Expand Down Expand Up @@ -477,6 +517,11 @@ interface types {
/// called to signal that the response is complete. If the `outgoing-body`
/// is dropped without calling `outgoing-body.finalize`, the implementation
/// should treat the body as corrupted.
///
/// Fails if the body's `outgoing-request` or `outgoing-response` was
/// constructed with a Content-Length header, and the contents written
/// to the body (via `write`) does not match the value given in the
/// Content-Length.
finish: static func(
this: outgoing-body,
trailers: option<trailers>
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/io/error.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:io@0.2.0-rc-2023-11-05;
package wasi:io@0.2.0-rc-2023-11-10;


interface error {
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/io/poll.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:io@0.2.0-rc-2023-11-05;
package wasi:io@0.2.0-rc-2023-11-10;

/// A poll API intended to let users wait for I/O events on multiple handles
/// at once.
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/io/streams.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:io@0.2.0-rc-2023-11-05;
package wasi:io@0.2.0-rc-2023-11-10;

/// WASI I/O is an I/O abstraction API which is currently focused on providing
/// stream types.
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-http/wit/deps/io/world.wit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasi:io@0.2.0-rc-2023-11-05;
package wasi:io@0.2.0-rc-2023-11-10;

world imports {
import streams;
Expand Down
1 change: 1 addition & 0 deletions crates/wasi-http/wit/deps/random/insecure-seed.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package wasi:random@0.2.0-rc-2023-11-10;
/// The insecure-seed interface for seeding hash-map DoS resistance.
///
/// It is intended to be portable at least between Unix-family platforms and
Expand Down
1 change: 1 addition & 0 deletions crates/wasi-http/wit/deps/random/insecure.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package wasi:random@0.2.0-rc-2023-11-10;
/// The insecure interface for insecure pseudo-random numbers.
///
/// It is intended to be portable at least between Unix-family platforms and
Expand Down
1 change: 1 addition & 0 deletions crates/wasi-http/wit/deps/random/random.wit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package wasi:random@0.2.0-rc-2023-11-10;
/// WASI Random is a random data API.
///
/// It is intended to be portable at least between Unix-family platforms and
Expand Down
Loading

0 comments on commit 1e3155d

Please sign in to comment.