diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a618099..5bc3848 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,6 +11,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: WebAssembly/wit-abi-up-to-date@v6 - with: - wit-abi-tag: wit-abi-0.6.0 + - uses: WebAssembly/wit-abi-up-to-date@v17 diff --git a/imports.md b/imports.md new file mode 100644 index 0000000..807fc2d --- /dev/null +++ b/imports.md @@ -0,0 +1,812 @@ +

World imports

+ +

Import interface wasi:io/error@0.2.0

+
+

Types

+

resource error

+

A 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>.

+

The set of functions which can "downcast" an error into a more +concrete type is open.

+

Functions

+

[method]error.to-debug-string: func

+

Returns a string that is suitable to assist humans in debugging +this error.

+

WARNING: The returned string should not be consumed mechanically! +It may change across platforms, hosts, or other implementation +details. Parsing this string is a major platform-compatibility +hazard.

+
Params
+ +
Return values
+ +

Import interface wasi:io/poll@0.2.0

+

A poll API intended to let users wait for I/O events on multiple handles +at once.

+
+

Types

+

resource pollable

+

pollable represents a single I/O event which may be ready, or not.

+

Functions

+

[method]pollable.ready: func

+

Return the readiness of a pollable. This function never blocks.

+

Returns true when the pollable is ready, and false otherwise.

+
Params
+ +
Return values
+ +

[method]pollable.block: func

+

block returns immediately if the pollable is ready, and otherwise +blocks until ready.

+

This function is equivalent to calling poll.poll on a list +containing only this pollable.

+
Params
+ +

poll: func

+

Poll for completion on a set of pollables.

+

This function takes a list of pollables, which identify I/O sources of +interest, and waits until one or more of the events is ready for I/O.

+

The result list<u32> contains one or more indices of handles in the +argument list that is ready for I/O.

+

If the list contains more elements than can be indexed with a u32 +value, this function traps.

+

A timeout can be implemented by adding a pollable from the +wasi-clocks API to the list.

+

This function does not return a result; polling in itself does not +do any I/O so it doesn't fail. If any of the I/O sources identified by +the pollables has an error, it is indicated by marking the source as +being reaedy for I/O.

+
Params
+ +
Return values
+ +

Import interface wasi:io/streams@0.2.0

+

WASI I/O is an I/O abstraction API which is currently focused on providing +stream types.

+

In the future, the component model is expected to add built-in stream types; +when it does, they are expected to subsume this API.

+
+

Types

+

type error

+

error

+

+#### `type pollable` +[`pollable`](#pollable) +

+#### `variant stream-error` +

An error for input-stream and output-stream operations.

+
Variant Cases
+ +

resource input-stream

+

An 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-stream

+

An 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.

+

Functions

+

[method]input-stream.read: func

+

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 +empty when no bytes are available for reading at this time. The +pollable given by subscribe will be ready when more bytes are +available.

+

This function fails with a stream-error when the operation +encounters an error, giving last-operation-failed, or when the +stream is closed, giving closed.

+

When the caller gives a len of 0, it represents a request to +read 0 bytes. If the stream is still open, this call should +succeed and return an empty list, or otherwise fail with closed.

+

The len parameter is a u64, which could represent a list of u8 which +is not possible to allocate in wasm32, or not desirable to allocate as +as a return value by the callee. The callee may return a list of bytes +less than len in size while more bytes are available for reading.

+
Params
+ +
Return values
+ +

[method]input-stream.blocking-read: func

+

Read bytes from a stream, after blocking until at least one byte can +be read. Except for blocking, behavior is identical to read.

+
Params
+ +
Return values
+ +

[method]input-stream.skip: func

+

Skip bytes from a stream. Returns number of bytes skipped.

+

Behaves identical to read, except instead of returning a list +of bytes, returns the number of bytes consumed from the stream.

+
Params
+ +
Return values
+ +

[method]input-stream.blocking-skip: func

+

Skip bytes from a stream, after blocking until at least one byte +can be skipped. Except for blocking behavior, identical to skip.

+
Params
+ +
Return values
+ +

[method]input-stream.subscribe: func

+

Create a pollable which will resolve once either the specified stream +has bytes available to read or the other end of the stream has been +closed. +The created pollable is a child resource of the input-stream. +Implementations may trap if the input-stream is dropped before +all derived pollables created with this function are dropped.

+
Params
+ +
Return values
+ +

[method]output-stream.check-write: func

+

Check readiness for writing. This function never blocks.

+

Returns the number of bytes permitted for the next call to write, +or an error. Calling write with more bytes than this function has +permitted will trap.

+

When this function returns 0 bytes, the subscribe pollable will +become ready when this function will report at least 1 byte, or an +error.

+
Params
+ +
Return values
+ +

[method]output-stream.write: func

+

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.

+

returns Err(closed) without writing if the stream has closed since +the last call to check-write provided a permit.

+
Params
+ +
Return values
+ +

[method]output-stream.blocking-write-and-flush: func

+

Perform a write of up to 4096 bytes, and then flush the stream. Block +until all of these operations are complete, or an error occurs.

+

This is a convenience wrapper around the use of check-write, +subscribe, write, and flush, and is implemented with the +following pseudo-code:

+
let pollable = this.subscribe();
+while !contents.is_empty() {
+  // Wait for the stream to become writable
+  pollable.block();
+  let Ok(n) = this.check-write(); // eliding error handling
+  let len = min(n, contents.len());
+  let (chunk, rest) = contents.split_at(len);
+  this.write(chunk  );            // eliding error handling
+  contents = rest;
+}
+this.flush();
+// Wait for completion of `flush`
+pollable.block();
+// Check for any errors that arose during `flush`
+let _ = this.check-write();         // eliding error handling
+
+
Params
+ +
Return values
+ +

[method]output-stream.flush: func

+

Request to flush buffered output. This function never blocks.

+

This tells the output-stream that the caller intends any buffered +output to be flushed. the output which is expected to be flushed +is all that has been passed to write prior to this call.

+

Upon calling this function, the output-stream will not accept any +writes (check-write will return ok(0)) until the flush has +completed. The subscribe pollable will become ready when the +flush has completed and the stream can accept more writes.

+
Params
+ +
Return values
+ +

[method]output-stream.blocking-flush: func

+

Request to flush buffered output, and block until flush completes +and stream is ready for writing again.

+
Params
+ +
Return values
+ +

[method]output-stream.subscribe: func

+

Create a pollable which will resolve once the output-stream +is ready for more writing, or an error has occured. When this +pollable is ready, check-write will return ok(n) with n>0, or an +error.

+

If the stream is closed, this pollable is always ready immediately.

+

The created pollable is a child resource of the output-stream. +Implementations may trap if the output-stream is dropped before +all derived pollables created with this function are dropped.

+
Params
+ +
Return values
+ +

[method]output-stream.write-zeroes: func

+

Write zeroes to a stream.

+

This should be used precisely like write with the exact same +preconditions (must use check-write first), but instead of +passing a list of bytes, you simply pass the number of zero-bytes +that should be written.

+
Params
+ +
Return values
+ +

[method]output-stream.blocking-write-zeroes-and-flush: func

+

Perform a write of up to 4096 zeroes, and then flush the stream. +Block until all of these operations are complete, or an error +occurs.

+

This is a convenience wrapper around the use of check-write, +subscribe, write-zeroes, and flush, and is implemented with +the following pseudo-code:

+
let pollable = this.subscribe();
+while num_zeroes != 0 {
+  // Wait for the stream to become writable
+  pollable.block();
+  let Ok(n) = this.check-write(); // eliding error handling
+  let len = min(n, num_zeroes);
+  this.write-zeroes(len);         // eliding error handling
+  num_zeroes -= len;
+}
+this.flush();
+// Wait for completion of `flush`
+pollable.block();
+// Check for any errors that arose during `flush`
+let _ = this.check-write();         // eliding error handling
+
+
Params
+ +
Return values
+ +

[method]output-stream.splice: func

+

Read from one stream and write to another.

+

The behavior of splice is equivelant to:

+
    +
  1. calling check-write on the output-stream
  2. +
  3. calling read on the input-stream with the smaller of the +check-write permitted length and the len provided to splice
  4. +
  5. calling write on the output-stream with that read data.
  6. +
+

Any error reported by the call to check-write, read, or +write ends the splice and reports that error.

+

This function returns the number of bytes transferred; it may be less +than len.

+
Params
+ +
Return values
+ +

[method]output-stream.blocking-splice: func

+

Read from one stream and write to another, with blocking.

+

This is similar to splice, except that it blocks until the +output-stream is ready for writing, and the input-stream +is ready for reading, before performing the splice.

+
Params
+ +
Return values
+ +

Import interface wasi:blobstore/types@0.1.0

+

Types used by blobstore

+
+

Types

+

type input-stream

+

input-stream

+

+#### `type output-stream` +[`output-stream`](#output_stream) +

+#### `type container-name` +`string` +

name of a container, a collection of objects. +The container name may be any valid UTF-8 string. +

type object-name

+

string

+

name of an object within a container +The object name may be any valid UTF-8 string. +

type timestamp

+

u64

+

TODO: define timestamp to include seconds since +Unix epoch and nanoseconds +https://github.com/WebAssembly/wasi-blob-store/issues/7 +

type object-size

+

u64

+

size of an object, in bytes +

type error

+

string

+

+#### `record container-metadata` +

information about a container

+
Record Fields
+ +

record object-metadata

+

information about an object

+
Record Fields
+ +

record object-id

+

identifier for an object that includes its container name

+
Record Fields
+ +

resource outgoing-value

+

A data is the data stored in a data blob. The value can be of any type +that can be represented in a byte array. It provides a way to write the value +to the output-stream defined in the wasi-io interface. +Soon: switch to resource value { ... }

+

resource incoming-value

+

A incoming-value is a wrapper around a value. It provides a way to read the value +from the input-stream defined in the wasi-io interface.

+

The incoming-value provides two ways to consume the value:

+
    +
  1. incoming-value-consume-sync consumes the value synchronously and returns the +value as a list of bytes.
  2. +
  3. incoming-value-consume-async consumes the value asynchronously and returns the +value as an input-stream. +Soon: switch to resource incoming-value { ... }
  4. +
+

type incoming-value-async-body

+

input-stream

+

+#### `type incoming-value-sync-body` +[`incoming-value-sync-body`](#incoming_value_sync_body) +

+---- +

Functions

+

[static]outgoing-value.new-outgoing-value: func

+
Return values
+ +

[method]outgoing-value.outgoing-value-write-body: func

+
Params
+ +
Return values
+ +

[method]incoming-value.incoming-value-consume-sync: func

+
Params
+ +
Return values
+ +

[method]incoming-value.incoming-value-consume-async: func

+
Params
+ +
Return values
+ +

[method]incoming-value.size: func

+
Params
+ +
Return values
+ +

Import interface wasi:blobstore/container@0.1.0

+

a Container is a collection of objects

+
+

Types

+

type input-stream

+

input-stream

+

+#### `type output-stream` +[`output-stream`](#output_stream) +

+#### `type container-metadata` +[`container-metadata`](#container_metadata) +

+#### `type error` +[`error`](#error) +

+#### `type incoming-value` +[`incoming-value`](#incoming_value) +

+#### `type object-metadata` +[`object-metadata`](#object_metadata) +

+#### `type object-name` +[`object-name`](#object_name) +

+#### `type outgoing-value` +[`outgoing-value`](#outgoing_value) +

+#### `resource container` +

this defines the container resource

+

resource stream-object-names

+

this defines the stream-object-names resource which is a representation of stream

+

Functions

+

[method]container.name: func

+

returns container name

+
Params
+ +
Return values
+ +

[method]container.info: func

+

returns container metadata

+
Params
+ +
Return values
+ +

[method]container.get-data: func

+

retrieves an object or portion of an object, as a resource. +Start and end offsets are inclusive. +Once a data-blob resource has been created, the underlying bytes are held by the blobstore service for the lifetime +of the data-blob resource, even if the object they came from is later deleted.

+
Params
+ +
Return values
+ +

[method]container.write-data: func

+

creates or replaces an object with the data blob.

+
Params
+ +
Return values
+ +

[method]container.list-objects: func

+

returns list of objects in the container. Order is undefined.

+
Params
+ +
Return values
+ +

[method]container.delete-object: func

+

deletes object. +does not return error if object did not exist.

+
Params
+ +
Return values
+ +

[method]container.delete-objects: func

+

deletes multiple objects in the container

+
Params
+ +
Return values
+ +

[method]container.has-object: func

+

returns true if the object exists in this container

+
Params
+ +
Return values
+ +

[method]container.object-info: func

+

returns metadata for the object

+
Params
+ +
Return values
+ +

[method]container.clear: func

+

removes all objects within the container, leaving the container empty.

+
Params
+ +
Return values
+ +

[method]stream-object-names.read-stream-object-names: func

+

reads the next number of objects from the stream

+

This function returns the list of objects read, and a boolean indicating if the end of the stream was reached.

+
Params
+ +
Return values
+ +

[method]stream-object-names.skip-stream-object-names: func

+

skip the next number of objects in the stream

+

This function returns the number of objects skipped, and a boolean indicating if the end of the stream was reached.

+
Params
+ +
Return values
+ +

Import interface wasi:blobstore/blobstore@0.1.0

+

wasi-cloud Blobstore service definition

+
+

Types

+

type container

+

container

+

+#### `type error` +[`error`](#error) +

+#### `type container-name` +[`container-name`](#container_name) +

+#### `type object-id` +[`object-id`](#object_id) +

+---- +

Functions

+

create-container: func

+

creates a new empty container

+
Params
+ +
Return values
+ +

get-container: func

+

retrieves a container by name

+
Params
+ +
Return values
+ +

delete-container: func

+

deletes a container and all objects within it

+
Params
+ +
Return values
+ +

container-exists: func

+

returns true if the container exists

+
Params
+ +
Return values
+ +

copy-object: func

+

copies (duplicates) an object, to the same or a different container. +returns an error if the target container does not exist. +overwrites destination object if it already existed.

+
Params
+ +
Return values
+ +

move-object: func

+

moves or renames an object, to the same or a different container +returns an error if the destination container does not exist. +overwrites destination object if it already existed.

+
Params
+ +
Return values
+ diff --git a/wit/container.wit b/wit/container.wit index dcc9881..f4c577e 100644 --- a/wit/container.wit +++ b/wit/container.wit @@ -1,6 +1,6 @@ // a Container is a collection of objects interface container { - use wasi:io/streams@0.2.0-rc-2023-11-10.{ + use wasi:io/streams@0.2.0.{ input-stream, output-stream, }; diff --git a/wit/deps.lock b/wit/deps.lock index 80cf335..dcc8282 100644 --- a/wit/deps.lock +++ b/wit/deps.lock @@ -1,4 +1,4 @@ [io] -url = "https://github.com/WebAssembly/wasi-io/archive/v0.2.0-rc-2023-11-10.tar.gz" -sha256 = "f2e6127b235c37c06be675a904d6acf08db953ea688d78c42892c6ad3bd194e4" -sha512 = "32feefbc115c34bf6968cb6e9dc15e755698ee90648e5a5d84448917c36a318bd61b401195eb64330e2475e1d098bfb8dee1440d594a68e0797748762bd84ae5" +url = "https://github.com/WebAssembly/wasi-io/archive/v0.2.0.tar.gz" +sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c" +sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb" diff --git a/wit/deps.toml b/wit/deps.toml index 1112346..bb31cd7 100644 --- a/wit/deps.toml +++ b/wit/deps.toml @@ -1 +1 @@ -io = "https://github.com/WebAssembly/wasi-io/archive/v0.2.0-rc-2023-11-10.tar.gz" +io = "https://github.com/WebAssembly/wasi-io/archive/v0.2.0.tar.gz" diff --git a/wit/deps/io/error.wit b/wit/deps/io/error.wit index 31918ac..22e5b64 100644 --- a/wit/deps/io/error.wit +++ b/wit/deps/io/error.wit @@ -1,4 +1,4 @@ -package wasi:io@0.2.0-rc-2023-11-10; +package wasi:io@0.2.0; interface error { diff --git a/wit/deps/io/poll.wit b/wit/deps/io/poll.wit index bddde3c..ddc67f8 100644 --- a/wit/deps/io/poll.wit +++ b/wit/deps/io/poll.wit @@ -1,9 +1,9 @@ -package wasi:io@0.2.0-rc-2023-11-10; +package wasi:io@0.2.0; /// A poll API intended to let users wait for I/O events on multiple handles /// at once. interface poll { - /// `pollable` epresents a single I/O event which may be ready, or not. + /// `pollable` represents a single I/O event which may be ready, or not. resource pollable { /// Return the readiness of a pollable. This function never blocks. diff --git a/wit/deps/io/streams.wit b/wit/deps/io/streams.wit index e7e1b68..6d2f871 100644 --- a/wit/deps/io/streams.wit +++ b/wit/deps/io/streams.wit @@ -1,4 +1,4 @@ -package wasi:io@0.2.0-rc-2023-11-10; +package wasi:io@0.2.0; /// WASI I/O is an I/O abstraction API which is currently focused on providing /// stream types. @@ -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. /// @@ -131,7 +142,7 @@ interface streams { /// let pollable = this.subscribe(); /// while !contents.is_empty() { /// // Wait for the stream to become writable - /// poll-one(pollable); + /// pollable.block(); /// let Ok(n) = this.check-write(); // eliding error handling /// let len = min(n, contents.len()); /// let (chunk, rest) = contents.split_at(len); @@ -140,7 +151,7 @@ interface streams { /// } /// this.flush(); /// // Wait for completion of `flush` - /// poll-one(pollable); + /// pollable.block(); /// // Check for any errors that arose during `flush` /// let _ = this.check-write(); // eliding error handling /// ``` @@ -178,7 +189,7 @@ interface streams { /// Write zeroes to a stream. /// - /// this should be used precisely like `write` with the exact same + /// This should be used precisely like `write` with the exact same /// preconditions (must use check-write first), but instead of /// passing a list of bytes, you simply pass the number of zero-bytes /// that should be written. @@ -199,7 +210,7 @@ interface streams { /// let pollable = this.subscribe(); /// while num_zeroes != 0 { /// // Wait for the stream to become writable - /// poll-one(pollable); + /// pollable.block(); /// let Ok(n) = this.check-write(); // eliding error handling /// let len = min(n, num_zeroes); /// this.write-zeroes(len); // eliding error handling @@ -207,7 +218,7 @@ interface streams { /// } /// this.flush(); /// // Wait for completion of `flush` - /// poll-one(pollable); + /// pollable.block(); /// // Check for any errors that arose during `flush` /// let _ = this.check-write(); // eliding error handling /// ``` diff --git a/wit/deps/io/world.wit b/wit/deps/io/world.wit index 8243da2..5f0b43f 100644 --- a/wit/deps/io/world.wit +++ b/wit/deps/io/world.wit @@ -1,4 +1,4 @@ -package wasi:io@0.2.0-rc-2023-11-10; +package wasi:io@0.2.0; world imports { import streams; diff --git a/wit/types.wit b/wit/types.wit index b15f80f..fed8482 100644 --- a/wit/types.wit +++ b/wit/types.wit @@ -1,6 +1,6 @@ // Types used by blobstore interface types { - use wasi:io/streams@0.2.0-rc-2023-11-10.{input-stream, output-stream}; + use wasi:io/streams@0.2.0.{input-stream, output-stream}; // name of a container, a collection of objects. // The container name may be any valid UTF-8 string.