diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b456232..b944a0d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,5 +10,5 @@ jobs: name: Check ABI files are up-to-date runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: WebAssembly/wit-abi-up-to-date@v16 + - uses: actions/checkout@v4 + - uses: WebAssembly/wit-abi-up-to-date@v17 diff --git a/imports.md b/imports.md index 55647e8..0d295cc 100644 --- a/imports.md +++ b/imports.md @@ -12,7 +12,21 @@
resource errorA resource which represents some error information.
+The only method provided by this resource is to-debug-string,
+which provides some human-readable information about the error.
In the wasi:io package, this resource is returned through the
+wasi:io/streams/stream-error type.
To provide more specific error information, other interfaces may
+provide functions to further "downcast" this error into more specific
+error information. For example, errors returned in streams derived
+from filesystem types to be described using the filesystem's own
+error-code type, using the function
+wasi:filesystem/types/filesystem-error-code, which takes a parameter
+borrow<error> and returns
+option<wasi:filesystem/types/error-code>.
error into a more
+concrete type is open.[method]error.to-debug-string: funcReturns a string that is suitable to assist humans in debugging @@ -35,7 +49,7 @@ at once.
resource pollablepollable represents a single I/O event which may be ready, or not.[method]pollable.ready: funcReturn the readiness of a pollable. This function never blocks.
@@ -109,11 +123,28 @@ future operations.resource input-streamAn input bytestream.
+input-streams are non-blocking to the extent practical on underlying
+platforms. I/O operations always return promptly; if fewer bytes are
+promptly available than requested, they return the number of bytes promptly
+available, which could even be zero. To wait for data to be available,
+use the subscribe function to obtain a pollable which can be polled
+for using wasi:io/poll.
resource output-streamAn output bytestream.
+output-streams are non-blocking to the extent practical on
+underlying platforms. Except where specified otherwise, I/O operations also
+always return promptly, after the number of bytes that can be written
+promptly, which could even be zero. To wait for the stream to be ready to
+accept data, the subscribe function to obtain a pollable which can be
+polled for using wasi:io/poll.[method]input-stream.read: funcPerform a non-blocking read from the stream.
+When the source of a read is binary data, the bytes from the source
+are returned verbatim. When the source of a read is known to the
+implementation to be text, bytes containing the UTF-8 encoding of the
+text are returned.
This function returns a list of bytes containing the read data,
when successful. The returned list will contain up to len bytes;
it may return fewer than requested, but not more. The list is
@@ -209,6 +240,11 @@ error.
[method]output-stream.write: funcPerform a write. This function never blocks.
+When the destination of a write is binary data, the bytes from
+contents are written verbatim. When the destination of a write is
+known to the implementation to be text, the bytes of contents are
+transcoded from UTF-8 into the encoding of the destination and then
+written.
Precondition: check-write gave permit of Ok(n) and contents has a length of less than or equal to n. Otherwise, this function will trap.
returns Err(closed) without writing if the stream has closed since diff --git a/wit/streams.wit b/wit/streams.wit index f6f7fe0..82e6e07 100644 --- a/wit/streams.wit +++ b/wit/streams.wit @@ -32,6 +32,11 @@ interface streams { resource input-stream { /// Perform a non-blocking read from the stream. /// + /// When the source of a `read` is binary data, the bytes from the source + /// are returned verbatim. When the source of a `read` is known to the + /// implementation to be text, bytes containing the UTF-8 encoding of the + /// text are returned. + /// /// This function returns a list of bytes containing the read data, /// when successful. The returned list will contain up to `len` bytes; /// it may return fewer than requested, but not more. The list is @@ -111,6 +116,12 @@ interface streams { /// Perform a write. This function never blocks. /// + /// When the destination of a `write` is binary data, the bytes from + /// `contents` are written verbatim. When the destination of a `write` is + /// known to the implementation to be text, the bytes of `contents` are + /// transcoded from UTF-8 into the encoding of the destination and then + /// written. + /// /// Precondition: check-write gave permit of Ok(n) and contents has a /// length of less than or equal to n. Otherwise, this function will trap. ///