diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 767e091..2864956 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,7 +18,6 @@ jobs: ./wit-deps lock git add -N wit/deps git diff --exit-code - - uses: WebAssembly/wit-abi-up-to-date@v17 + - uses: WebAssembly/wit-abi-up-to-date@v21 with: - wit-bindgen: '0.16.0' worlds: "command imports" diff --git a/command.md b/command.md index 04dfb7b..cdd51c1 100644 --- a/command.md +++ b/command.md @@ -2,45 +2,45 @@ -

Import interface wasi:cli/environment@0.2.0

+

Import interface wasi:cli/environment@0.2.0


Functions

-

get-environment: func

+

get-environment: func

Get the POSIX-style environment variables.

Each environment variable is provided as a pair of string variable names and string value.

@@ -51,49 +51,47 @@ values each time it is called.

-

get-arguments: func

+

get-arguments: func

Get the POSIX-style arguments to the program.

Return values
-

initial-cwd: func

+

initial-cwd: func

Return a path that programs should use as their initial current working directory, interpreting . as shorthand for this.

Return values
-

Import interface wasi:cli/exit@0.2.0

+

Import interface wasi:cli/exit@0.2.0


Functions

-

exit: func

+

exit: func

Exit the current instance and any linked instances.

Params
-

Import interface wasi:io/error@0.2.0

+

Import interface wasi:io/error@0.2.0


Types

-

resource error

+

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

+offer functions to "downcast" this error into more specific types. For example, +errors returned from streams derived from filesystem types can be described using +the filesystem's own error-code type. This is done using the function +wasi:filesystem/types/filesystem-error-code, which takes a borrow<error> +parameter and returns an 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

+

[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! @@ -102,92 +100,95 @@ details. Parsing this string is a major platform-compatibility hazard.

Params
Return values
-

Import interface wasi:io/poll@0.2.0

+

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

+

resource pollable

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

Functions

-

[method]pollable.ready: func

+

[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

+

[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: 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.

+

This function traps if either:

+

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.

+being ready for I/O.

Params
Return values
-

Import interface wasi:io/streams@0.2.0

+

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

+

type error

error

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

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

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

Variant Cases
-

resource input-stream

+

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 @@ -195,7 +196,7 @@ 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

+

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 @@ -204,7 +205,7 @@ 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

+

[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 @@ -228,51 +229,51 @@ 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

+

[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

+

[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

+

[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

+

[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. @@ -281,13 +282,13 @@ Implementations may trap if the input-streampollables created with this function are dropped.

Params
Return values
-

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

+

[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 @@ -297,13 +298,13 @@ become ready when this function will report at least 1 byte, or an error.

Params
Return values
-

[method]output-stream.write: func

+

[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 @@ -316,14 +317,14 @@ length of less than or equal to n. Otherwise, this function will trap.

the last call to check-write provided a permit.

Params
Return values
-

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

+

[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, @@ -347,14 +348,14 @@ let _ = this.check-write(); // eliding error handling

Params
Return values
-

[method]output-stream.flush: func

+

[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 @@ -365,24 +366,24 @@ 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

+

[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

+

[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 @@ -393,13 +394,13 @@ Implementations may trap if the output-streampollables created with this function are dropped.

Params
Return values
-

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

+

[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 @@ -407,14 +408,14 @@ 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

+

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

@@ -438,14 +439,14 @@ let _ = this.check-write(); // eliding error handling
Params
Return values
-

[method]output-stream.splice: func

+

[method]output-stream.splice: func

Read from one stream and write to another.

The behavior of splice is equivelant to:

    @@ -460,161 +461,160 @@ let _ = this.check-write(); // eliding error handling than len.

    Params
    Return values
    -

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

    +

    [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:cli/stdin@0.2.0

    +

    Import interface wasi:cli/stdin@0.2.0


    Types

    -

    type input-stream

    +

    type input-stream

    input-stream

    ----

    Functions

    -

    get-stdin: func

    +

    get-stdin: func

    Return values
    -

    Import interface wasi:cli/stdout@0.2.0

    +

    Import interface wasi:cli/stdout@0.2.0


    Types

    -

    type output-stream

    +

    type output-stream

    output-stream

    ----

    Functions

    -

    get-stdout: func

    +

    get-stdout: func

    Return values
    -

    Import interface wasi:cli/stderr@0.2.0

    +

    Import interface wasi:cli/stderr@0.2.0


    Types

    -

    type output-stream

    +

    type output-stream

    output-stream

    ----

    Functions

    -

    get-stderr: func

    +

    get-stderr: func

    Return values
    -

    Import interface wasi:cli/terminal-input@0.2.0

    +

    Import interface wasi:cli/terminal-input@0.2.0

    Terminal input.

    In the future, this may include functions for disabling echoing, disabling input buffering so that keyboard events are sent through immediately, querying supported features, and so on.


    Types

    -

    resource terminal-input

    +

    resource terminal-input

    The input side of a terminal.

    -

    Import interface wasi:cli/terminal-output@0.2.0

    +

    Import interface wasi:cli/terminal-output@0.2.0

    Terminal output.

    In the future, this may include functions for querying the terminal size, being notified of terminal size changes, querying supported features, and so on.


    Types

    -

    resource terminal-output

    +

    resource terminal-output

    The output side of a terminal.

    -

    Import interface wasi:cli/terminal-stdin@0.2.0

    +

    Import interface wasi:cli/terminal-stdin@0.2.0

    An interface providing an optional terminal-input for stdin as a link-time authority.


    Types

    -

    type terminal-input

    +

    type terminal-input

    terminal-input

    ----

    Functions

    -

    get-terminal-stdin: func

    +

    get-terminal-stdin: func

    If stdin is connected to a terminal, return a terminal-input handle allowing further interaction with it.

    Return values
    -

    Import interface wasi:cli/terminal-stdout@0.2.0

    +

    Import interface wasi:cli/terminal-stdout@0.2.0

    An interface providing an optional terminal-output for stdout as a link-time authority.


    Types

    -

    type terminal-output

    +

    type terminal-output

    terminal-output

    ----

    Functions

    -

    get-terminal-stdout: func

    +

    get-terminal-stdout: func

    If stdout is connected to a terminal, return a terminal-output handle allowing further interaction with it.

    Return values
    -

    Import interface wasi:cli/terminal-stderr@0.2.0

    +

    Import interface wasi:cli/terminal-stderr@0.2.0

    An interface providing an optional terminal-output for stderr as a link-time authority.


    Types

    -

    type terminal-output

    +

    type terminal-output

    terminal-output

    ----

    Functions

    -

    get-terminal-stderr: func

    +

    get-terminal-stderr: func

    If stderr is connected to a terminal, return a terminal-output handle allowing further interaction with it.

    Return values
    -

    Import interface wasi:clocks/monotonic-clock@0.2.0

    +

    Import interface wasi:clocks/monotonic-clock@0.2.0

    WASI Monotonic Clock is a clock API intended to let users measure elapsed time.

    It is intended to be portable at least between Unix-family platforms and Windows.

    A monotonic clock is a clock which has an unspecified initial value, and successive reads of the clock will produce non-decreasing values.

    -

    It is intended for measuring elapsed time.


    Types

    -

    type pollable

    +

    type pollable

    pollable

    -#### `type instant` +#### `type instant` `u64`

    An instant in time, in nanoseconds. An instant is relative to an unspecified initial value, and can only be compared to instances from the same monotonic-clock. -

    type duration

    +

    type duration

    u64

    A duration of time, in nanoseconds.


    Functions

    -

    now: func

    +

    now: func

    Read the current value of the clock.

    The clock is monotonic, therefore calling this function repeatedly will produce a sequence of non-decreasing values.

    @@ -622,37 +622,36 @@ produce a sequence of non-decreasing values.

    -

    resolution: func

    +

    resolution: func

    Query the resolution of the clock. Returns the duration of time corresponding to a clock tick.

    Return values
    -

    subscribe-instant: func

    +

    subscribe-instant: func

    Create a pollable which will resolve once the specified instant -occured.

    +has occured.

    Params
    Return values
    -

    subscribe-duration: func

    -

    Create a pollable which will resolve once the given duration has -elapsed, starting at the time at which this function was called. -occured.

    +

    subscribe-duration: func

    +

    Create a pollable that will resolve after the specified duration has +elapsed from the time this function is invoked.

    Params
    Return values
    -

    Import interface wasi:clocks/wall-clock@0.2.0

    +

    Import interface wasi:clocks/wall-clock@0.2.0

    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.

    @@ -665,16 +664,16 @@ monotonic, making it unsuitable for measuring elapsed time.

    It is intended for reporting the current date and time for humans.


    Types

    -

    record datetime

    +

    record datetime

    A time and date in seconds plus nanoseconds.

    Record Fields

    Functions

    -

    now: func

    +

    now: func

    Read the current value of the clock.

    This clock is not monotonic, therefore calling this function repeatedly will not necessarily produce a sequence of non-decreasing values.

    @@ -686,14 +685,14 @@ also known as Unix Time.
  1. datetime
  2. -

    resolution: func

    +

    resolution: func

    Query the resolution of the clock.

    The nanoseconds field of the output is always less than 1000000000.

    Return values
    -

    Import interface wasi:filesystem/types@0.2.0

    +

    Import interface wasi:filesystem/types@0.2.0

    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.

    @@ -713,75 +712,75 @@ underlying filesystem, the function fails with WASI filesystem path resolution.


    Types

    -

    type input-stream

    +

    type input-stream

    input-stream

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

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

    -#### `type datetime` +#### `type datetime` [`datetime`](#datetime)

    -#### `type filesize` +#### `type filesize` `u64`

    File size or length of a region within a file. -

    enum descriptor-type

    +

    enum descriptor-type

    The type of a filesystem object referenced by a descriptor.

    Note: This was called filetype in earlier versions of WASI.

    Enum Cases
    -

    flags descriptor-flags

    +

    flags descriptor-flags

    Descriptor flags.

    Note: This was called fdflags in earlier versions of WASI.

    Flags members
    -

    flags path-flags

    +

    flags path-flags

    Flags determining the method of how paths are resolved.

    Flags members
    -

    flags open-flags

    +

    flags open-flags

    Open flags used by open-at.

    Flags members
    -

    type link-count

    +

    type link-count

    u64

    Number of hard links to an inode. -

    record descriptor-stat

    +

    record descriptor-stat

    File attributes.

    Note: This was called filestat in earlier versions of WASI.

    Record Fields
    -

    variant new-timestamp

    +

    variant new-timestamp

    When setting a timestamp, this gives the value to set it to.

    Variant Cases
    -

    record directory-entry

    +

    record directory-entry

    A directory entry.

    Record Fields
    -

    enum error-code

    +

    enum error-code

    Error codes returned by functions, similar to errno in POSIX. Not all of these error codes are returned by the functions provided by this API; some are used in higher-level library layers, and others are provided @@ -925,211 +924,211 @@ merely for alignment with POSIX.

    Enum Cases
    -

    enum advice

    +

    enum advice

    File or memory access pattern advisory information.

    Enum Cases
    -

    record metadata-hash-value

    +

    record metadata-hash-value

    A 128-bit hash value, split into parts because wasm doesn't have a 128-bit integer type.

    Record Fields
    -

    resource descriptor

    +

    resource descriptor

    A descriptor is a reference to a filesystem object, which may be a file, directory, named pipe, special file, or other object on which filesystem calls may be made.

    -

    resource directory-entry-stream

    +

    resource directory-entry-stream

    A stream of directory entries.

    Functions

    -

    [method]descriptor.read-via-stream: func

    +

    [method]descriptor.read-via-stream: func

    Return a stream for reading from a file, if available.

    May fail with an error-code describing why the file cannot be read.

    Multiple read, write, and append streams may be active on the same open @@ -1137,81 +1136,81 @@ file and they do not interfere with each other.

    Note: This allows using read-stream, which is similar to read in POSIX.

    Params
    Return values
    -

    [method]descriptor.write-via-stream: func

    +

    [method]descriptor.write-via-stream: func

    Return a stream for writing to a file, if available.

    May fail with an error-code describing why the file cannot be written.

    Note: This allows using write-stream, which is similar to write in POSIX.

    Params
    Return values
    -

    [method]descriptor.append-via-stream: func

    +

    [method]descriptor.append-via-stream: func

    Return a stream for appending to a file, if available.

    May fail with an error-code describing why the file cannot be appended.

    Note: This allows using write-stream, which is similar to write with O_APPEND in in POSIX.

    Params
    Return values
    -

    [method]descriptor.advise: func

    +

    [method]descriptor.advise: func

    Provide file advisory information on a descriptor.

    This is similar to posix_fadvise in POSIX.

    Params
    Return values
    -

    [method]descriptor.sync-data: func

    +

    [method]descriptor.sync-data: func

    Synchronize the data of a file to disk.

    This function succeeds with no effect if the file descriptor is not opened for writing.

    Note: This is similar to fdatasync in POSIX.

    Params
    Return values
    -

    [method]descriptor.get-flags: func

    +

    [method]descriptor.get-flags: func

    Get flags associated with a descriptor.

    Note: This returns similar flags to fcntl(fd, F_GETFL) in POSIX.

    Note: This returns the value that was the fs_flags value returned from fdstat_get in earlier versions of WASI.

    Params
    Return values
    -

    [method]descriptor.get-type: func

    +

    [method]descriptor.get-type: func

    Get the dynamic type of a descriptor.

    Note: This returns the same value as the type field of the fd-stat returned by stat, stat-at and similar.

    @@ -1221,40 +1220,40 @@ by fstat in POSIX.

    from fdstat_get in earlier versions of WASI.

    Params
    Return values
    -

    [method]descriptor.set-size: func

    +

    [method]descriptor.set-size: func

    Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.

    Note: This was called fd_filestat_set_size in earlier versions of WASI.

    Params
    Return values
    -

    [method]descriptor.set-times: func

    +

    [method]descriptor.set-times: func

    Adjust the timestamps of an open file or directory.

    Note: This is similar to futimens in POSIX.

    Note: This was called fd_filestat_set_times in earlier versions of WASI.

    Params
    Return values
    -

    [method]descriptor.read: func

    +

    [method]descriptor.read: func

    Read from a descriptor, without using and updating the descriptor's offset.

    This function returns a list of bytes containing the data that was read, along with a bool which, when true, indicates that the end of the @@ -1265,15 +1264,15 @@ if the I/O operation is interrupted.

    Note: This is similar to pread in POSIX.

    Params
    Return values
    -

    [method]descriptor.write: func

    +

    [method]descriptor.write: func

    Write to a descriptor, without using and updating the descriptor's offset.

    It is valid to write past the end of a file; the file is extended to the extent of the write, with bytes between the previous end and the start of @@ -1282,15 +1281,15 @@ the write set to zero.

    Note: This is similar to pwrite in POSIX.

    Params
    Return values
    -

    [method]descriptor.read-directory: func

    +

    [method]descriptor.read-directory: func

    Read directory entries from a directory.

    On filesystems where directories contain entries referring to themselves and their parents, often named . and .. respectively, these entries @@ -1300,38 +1299,38 @@ directory. Multiple streams may be active on the same directory, and they do not interfere with each other.

    Params
    Return values
    -

    [method]descriptor.sync: func

    +

    [method]descriptor.sync: func

    Synchronize the data and metadata of a file to disk.

    This function succeeds with no effect if the file descriptor is not opened for writing.

    Note: This is similar to fsync in POSIX.

    Params
    Return values
    -

    [method]descriptor.create-directory-at: func

    +

    [method]descriptor.create-directory-at: func

    Create a directory.

    Note: This is similar to mkdirat in POSIX.

    Params
    Return values
    -

    [method]descriptor.stat: func

    +

    [method]descriptor.stat: func

    Return the attributes of an open file or directory.

    Note: This is similar to fstat in POSIX, except that it does not return device and inode information. For testing whether two descriptors refer to @@ -1341,13 +1340,13 @@ modified, use metadata-hash.

    Note: This was called fd_filestat_get in earlier versions of WASI.

    Params
    Return values
    -

    [method]descriptor.stat-at: func

    +

    [method]descriptor.stat-at: func

    Return the attributes of a file or directory.

    Note: This is similar to fstatat in POSIX, except that it does not return device and inode information. See the stat description for a @@ -1355,47 +1354,47 @@ discussion of alternatives.

    Note: This was called path_filestat_get in earlier versions of WASI.

    Params
    Return values
    -

    [method]descriptor.set-times-at: func

    +

    [method]descriptor.set-times-at: func

    Adjust the timestamps of a file or directory.

    Note: This is similar to utimensat in POSIX.

    Note: This was called path_filestat_set_times in earlier versions of WASI.

    Params
    Return values
    -

    [method]descriptor.link-at: func

    +

    [method]descriptor.link-at: func

    Create a hard link.

    Note: This is similar to linkat in POSIX.

    Params
    Return values
    -

    [method]descriptor.open-at: func

    +

    [method]descriptor.open-at: func

    Open a file or directory.

    The returned descriptor is not guaranteed to be the lowest-numbered descriptor not currently open/ it is randomized to prevent applications @@ -1412,86 +1411,86 @@ contains truncate or create, and the base descriptor d

    Note: This is similar to openat in POSIX.

    Params
    Return values
    -

    [method]descriptor.readlink-at: func

    +

    [method]descriptor.readlink-at: func

    Read the contents of a symbolic link.

    If the contents contain an absolute or rooted path in the underlying filesystem, this function fails with error-code::not-permitted.

    Note: This is similar to readlinkat in POSIX.

    Params
    Return values
    -

    [method]descriptor.remove-directory-at: func

    +

    [method]descriptor.remove-directory-at: func

    Remove a directory.

    Return error-code::not-empty if the directory is not empty.

    Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.

    Params
    Return values
    -

    [method]descriptor.rename-at: func

    +

    [method]descriptor.rename-at: func

    Rename a filesystem object.

    Note: This is similar to renameat in POSIX.

    Params
    Return values
    -

    [method]descriptor.symlink-at: func

    +

    [method]descriptor.symlink-at: func

    Create a symbolic link (also known as a "symlink").

    If old-path starts with /, the function fails with error-code::not-permitted.

    Note: This is similar to symlinkat in POSIX.

    Params
    Return values
    -

    [method]descriptor.unlink-file-at: func

    +

    [method]descriptor.unlink-file-at: func

    Unlink a filesystem object that is not a directory.

    Return error-code::is-directory if the path refers to a directory. Note: This is similar to unlinkat(fd, path, 0) in POSIX.

    Params
    Return values
    -

    [method]descriptor.is-same-object: func

    +

    [method]descriptor.is-same-object: func

    Test whether two descriptors refer to the same filesystem object.

    In POSIX, this corresponds to testing whether the two descriptors have the same device (st_dev) and inode (st_ino or d_ino) numbers. @@ -1499,14 +1498,14 @@ wasi-filesystem does not expose device and inode numbers, so this function may be used instead.

    Params
    Return values
    -

    [method]descriptor.metadata-hash: func

    +

    [method]descriptor.metadata-hash: func

    Return a hash of the metadata associated with a filesystem object referred to by a descriptor.

    This returns a hash of the last-modification timestamp and file size, and @@ -1526,37 +1525,37 @@ computed hash.

    However, none of these is required.

    Params
    Return values
    -

    [method]descriptor.metadata-hash-at: func

    +

    [method]descriptor.metadata-hash-at: func

    Return a hash of the metadata associated with a filesystem object referred to by a directory descriptor and a relative path.

    This performs the same hash computation as metadata-hash.

    Params
    Return values
    -

    [method]directory-entry-stream.read-directory-entry: func

    +

    [method]directory-entry-stream.read-directory-entry: func

    Read a single directory entry from a directory-entry-stream.

    Params
    Return values
    -

    filesystem-error-code: func

    +

    filesystem-error-code: func

    Attempts to extract a filesystem-related error-code from the stream error provided.

    Stream operations which return stream-error::last-operation-failed @@ -1567,34 +1566,34 @@ filesystem-related information about the error to return.

    errors are filesystem-related errors.

    Params
    Return values
    -

    Import interface wasi:filesystem/preopens@0.2.0

    +

    Import interface wasi:filesystem/preopens@0.2.0


    Types

    -

    type descriptor

    +

    type descriptor

    descriptor

    ----

    Functions

    -

    get-directories: func

    +

    get-directories: func

    Return the set of preopened directories, and their path.

    Return values
    -

    Import interface wasi:sockets/network@0.2.0

    +

    Import interface wasi:sockets/network@0.2.0


    Types

    -

    resource network

    +

    resource network

    An opaque resource that represents access to (a subset of) the network. This enables context-based security for networking. There is no need for this to map 1:1 to a physical network interface.

    -

    enum error-code

    +

    enum error-code

    Error codes.

    In theory, every API can return any error code. In practice, API's typically only return the errors documented per API @@ -1610,235 +1609,235 @@ combined with a couple of errors that are always possible:

    Enum Cases
    -

    enum ip-address-family

    +

    enum ip-address-family

    Enum Cases
    -

    tuple ipv4-address

    +

    tuple ipv4-address

    Tuple Fields
    -

    tuple ipv6-address

    +

    tuple ipv6-address

    Tuple Fields
    -

    variant ip-address

    +

    variant ip-address

    Variant Cases
    -

    record ipv4-socket-address

    +

    record ipv4-socket-address

    Record Fields
    -

    record ipv6-socket-address

    +

    record ipv6-socket-address

    Record Fields
    -

    variant ip-socket-address

    +

    variant ip-socket-address

    Variant Cases
    -

    Import interface wasi:sockets/instance-network@0.2.0

    +

    Import interface wasi:sockets/instance-network@0.2.0

    This interface provides a value-export of the default network handle..


    Types

    -

    type network

    +

    type network

    network

    ----

    Functions

    -

    instance-network: func

    +

    instance-network: func

    Get a handle to the default network.

    Return values
    -

    Import interface wasi:sockets/udp@0.2.0

    +

    Import interface wasi:sockets/udp@0.2.0


    Types

    -

    type pollable

    +

    type pollable

    pollable

    -#### `type network` +#### `type network` [`network`](#network)

    -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

    -#### `type ip-socket-address` +#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)

    -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

    -#### `record incoming-datagram` +#### `record incoming-datagram`

    A received datagram.

    Record Fields
    -

    record outgoing-datagram

    +

    record outgoing-datagram

    A datagram to be sent out.

    Record Fields
    Params
    Return values
    -

    [method]udp-socket.finish-bind: func

    +

    [method]udp-socket.finish-bind: func

    Params
    Return values
    -

    [method]udp-socket.stream: func

    +

    [method]udp-socket.stream: func

    Set up inbound & outbound communication channels, optionally to a specific peer.

    This function only changes the local socket configuration and does not generate any network traffic. On success, the remote-address of the socket is updated. The local-address may be updated as well, @@ -1941,14 +1940,14 @@ if (remote_address is Some) {

    Params
    Return values
    -

    [method]udp-socket.local-address: func

    +

    [method]udp-socket.local-address: func

    Get the current bound address.

    POSIX mentions:

    @@ -1969,13 +1968,13 @@ stored in the object pointed to by address is unspecified.

    Params
    Return values
    -

    [method]udp-socket.remote-address: func

    +

    [method]udp-socket.remote-address: func

    Get the address the socket is currently streaming to.

    Typical errors

    Params
    Return values
    -

    [method]udp-socket.address-family: func

    +

    [method]udp-socket.address-family: func

    Whether this is a IPv4 or IPv6 socket.

    Equivalent to the SO_DOMAIN socket option.

    Params
    Return values
    -

    [method]udp-socket.unicast-hop-limit: func

    +

    [method]udp-socket.unicast-hop-limit: func

    Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.

    If the provided value is 0, an invalid-argument error is returned.

    Typical errors

    @@ -2016,23 +2015,23 @@ stored in the object pointed to by address is unspecified.

    Params
    Return values
    -

    [method]udp-socket.set-unicast-hop-limit: func

    +

    [method]udp-socket.set-unicast-hop-limit: func

    Params
    Return values
    -

    [method]udp-socket.receive-buffer-size: func

    +

    [method]udp-socket.receive-buffer-size: func

    The kernel buffer space reserved for sends/receives on this socket.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2044,54 +2043,54 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]udp-socket.set-receive-buffer-size: func

    +

    [method]udp-socket.set-receive-buffer-size: func

    Params
    Return values
    -

    [method]udp-socket.send-buffer-size: func

    +

    [method]udp-socket.send-buffer-size: func

    Params
    Return values
    -

    [method]udp-socket.set-send-buffer-size: func

    +

    [method]udp-socket.set-send-buffer-size: func

    Params
    Return values
    -

    [method]udp-socket.subscribe: func

    +

    [method]udp-socket.subscribe: func

    Create a pollable which will resolve once the socket is ready for I/O.

    Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

    Params
    Return values
    -

    [method]incoming-datagram-stream.receive: func

    +

    [method]incoming-datagram-stream.receive: func

    Receive messages on the socket.

    This function attempts to receive up to max-results datagrams on the socket without blocking. The returned list may contain fewer elements than requested, but never more.

    @@ -2119,26 +2118,26 @@ This function never returns error(would-block).
    Params
    Return values
    -

    [method]incoming-datagram-stream.subscribe: func

    +

    [method]incoming-datagram-stream.subscribe: func

    Create a pollable which will resolve once the stream is ready to receive again.

    Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

    Params
    Return values
    -

    [method]outgoing-datagram-stream.check-send: func

    +

    [method]outgoing-datagram-stream.check-send: func

    Check readiness for sending. This function never blocks.

    Returns the number of datagrams permitted for the next call to send, or an error. Calling send with more datagrams than this function has @@ -2149,13 +2148,13 @@ error.

    Never returns would-block.

    Params
    Return values
    -

    [method]outgoing-datagram-stream.send: func

    +

    [method]outgoing-datagram-stream.send: func

    Send messages on the socket.

    This function attempts to send all provided datagrams on the socket without blocking and returns how many messages were actually sent (or queued for sending). This function never @@ -2190,43 +2189,43 @@ either check-send was not called or datagrams contains

    Params
    Return values
    -

    [method]outgoing-datagram-stream.subscribe: func

    +

    [method]outgoing-datagram-stream.subscribe: func

    Create a pollable which will resolve once the stream is ready to send again.

    Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

    Params
    Return values
    -

    Import interface wasi:sockets/udp-create-socket@0.2.0

    +

    Import interface wasi:sockets/udp-create-socket@0.2.0


    Types

    -

    type network

    +

    type network

    network

    -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

    -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

    -#### `type udp-socket` +#### `type udp-socket` [`udp-socket`](#udp_socket)

    ----

    Functions

    -

    create-udp-socket: func

    +

    create-udp-socket: func

    Create a new UDP socket.

    Similar to socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP) in POSIX. On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.

    @@ -2248,56 +2247,56 @@ the socket is effectively an in-memory configuration object, unable to communica
    Params
    Return values
    -

    Import interface wasi:sockets/tcp@0.2.0

    +

    Import interface wasi:sockets/tcp@0.2.0


    Types

    -

    type input-stream

    +

    type input-stream

    input-stream

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

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

    -#### `type duration` +#### `type duration` [`duration`](#duration)

    -#### `type network` +#### `type network` [`network`](#network)

    -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

    -#### `type ip-socket-address` +#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)

    -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

    -#### `enum shutdown-type` +#### `enum shutdown-type`

    Enum Cases
    -

    resource tcp-socket

    +

    resource tcp-socket

    A TCP socket resource.

    The socket can be in one of the following states:

    Note: Except where explicitly mentioned, whenever this documentation uses the term "bound" without backticks it actually means: in the bound state or higher. @@ -2319,7 +2318,7 @@ the term "bound" without backticks it actually means: in the bou network::error-code type, TCP socket methods may always return error(invalid-state) when in the closed state.

    Functions

    -

    [method]tcp-socket.start-bind: func

    +

    [method]tcp-socket.start-bind: func

    Bind the socket to a specific network on the provided IP address and port.

    If the IP address is zero (0.0.0.0 in IPv4, :: in IPv6), it is left to the implementation to decide which network interface(s) to bind to. @@ -2358,28 +2357,28 @@ don't want to make use of this ability can simply call the native

    Params
    Return values
    -

    [method]tcp-socket.finish-bind: func

    +

    [method]tcp-socket.finish-bind: func

    Params
    Return values
    -

    [method]tcp-socket.start-connect: func

    +

    [method]tcp-socket.start-connect: func

    Connect to a remote endpoint.

    On success:

      -
    • the socket is transitioned into the connection state.
    • +
    • the socket is transitioned into the connected state.
    • a pair of streams is returned that can be used to read & write to the connection

    After a failed connection attempt, the socket will be in the closed @@ -2420,24 +2419,24 @@ the SO_ERROR socket option, in case the poll signaled readiness.

    Params
    Return values
    -

    [method]tcp-socket.finish-connect: func

    +

    [method]tcp-socket.finish-connect: func

    Params
    Return values
    -

    [method]tcp-socket.start-listen: func

    +

    [method]tcp-socket.start-listen: func

    Start listening for new connections.

    Transitions the socket into the listening state.

    Unlike POSIX, the socket must already be explicitly bound.

    @@ -2464,22 +2463,22 @@ don't want to make use of this ability can simply call the native
    Params
    Return values
    -

    [method]tcp-socket.finish-listen: func

    +

    [method]tcp-socket.finish-listen: func

    Params
    Return values
    -

    [method]tcp-socket.accept: func

    +

    [method]tcp-socket.accept: func

    Accept a new client socket.

    The returned socket is bound and in the connected state. The following properties are inherited from the listener socket:

      @@ -2510,13 +2509,13 @@ a pair of streams that can be used to read & write to the connection.

    Params
    Return values
    -

    [method]tcp-socket.local-address: func

    +

    [method]tcp-socket.local-address: func

    Get the bound local address.

    POSIX mentions:

    @@ -2537,13 +2536,13 @@ stored in the object pointed to by address is unspecified.

    Params
    Return values
    -

    [method]tcp-socket.remote-address: func

    +

    [method]tcp-socket.remote-address: func

    Get the remote address.

    Typical errors

      @@ -2558,35 +2557,35 @@ stored in the object pointed to by address is unspecified.

    Params
    Return values
    -

    [method]tcp-socket.is-listening: func

    +

    [method]tcp-socket.is-listening: func

    Whether the socket is in the listening state.

    Equivalent to the SO_ACCEPTCONN socket option.

    Params
    Return values
      -
    • bool
    • +
    • bool
    -

    [method]tcp-socket.address-family: func

    +

    [method]tcp-socket.address-family: func

    Whether this is a IPv4 or IPv6 socket.

    Equivalent to the SO_DOMAIN socket option.

    Params
    Return values
    -

    [method]tcp-socket.set-listen-backlog-size: func

    +

    [method]tcp-socket.set-listen-backlog-size: func

    Hints the desired listen queue size. Implementations are free to ignore this.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded.

    @@ -2598,14 +2597,14 @@ Any other value will never cause an error, but it might be silently clamped and/
    Params
    Return values
    -

    [method]tcp-socket.keep-alive-enabled: func

    +

    [method]tcp-socket.keep-alive-enabled: func

    Enables or disables keepalive.

    The keepalive behavior can be adjusted using:

      @@ -2617,23 +2616,23 @@ These properties can be configured while keep-alive-enabled is fals

      Equivalent to the SO_KEEPALIVE socket option.

      Params
      Return values
      -

      [method]tcp-socket.set-keep-alive-enabled: func

      +

      [method]tcp-socket.set-keep-alive-enabled: func

      Params
      Return values
      -

      [method]tcp-socket.keep-alive-idle-time: func

      +

      [method]tcp-socket.keep-alive-idle-time: func

      Amount of time the connection has to be idle before TCP starts sending keepalive packets.

      If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2645,23 +2644,23 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]tcp-socket.set-keep-alive-idle-time: func

    +

    [method]tcp-socket.set-keep-alive-idle-time: func

    Params
    Return values
    -

    [method]tcp-socket.keep-alive-interval: func

    +

    [method]tcp-socket.keep-alive-interval: func

    The time between keepalive packets.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2673,23 +2672,23 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]tcp-socket.set-keep-alive-interval: func

    +

    [method]tcp-socket.set-keep-alive-interval: func

    Params
    Return values
    -

    [method]tcp-socket.keep-alive-count: func

    +

    [method]tcp-socket.keep-alive-count: func

    The maximum amount of keepalive packets TCP should send before aborting the connection.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2701,23 +2700,23 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]tcp-socket.set-keep-alive-count: func

    +

    [method]tcp-socket.set-keep-alive-count: func

    Params
    Return values
    -

    [method]tcp-socket.hop-limit: func

    +

    [method]tcp-socket.hop-limit: func

    Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.

    If the provided value is 0, an invalid-argument error is returned.

    Typical errors

    @@ -2726,23 +2725,23 @@ I.e. after setting a value, reading the same setting back may return a different
    Params
    Return values
    -

    [method]tcp-socket.set-hop-limit: func

    +

    [method]tcp-socket.set-hop-limit: func

    Params
    Return values
    -

    [method]tcp-socket.receive-buffer-size: func

    +

    [method]tcp-socket.receive-buffer-size: func

    The kernel buffer space reserved for sends/receives on this socket.

    If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2754,42 +2753,42 @@ I.e. after setting a value, reading the same setting back may return a different

    Params
    Return values
    -

    [method]tcp-socket.set-receive-buffer-size: func

    +

    [method]tcp-socket.set-receive-buffer-size: func

    Params
    Return values
    -

    [method]tcp-socket.send-buffer-size: func

    +

    [method]tcp-socket.send-buffer-size: func

    Params
    Return values
    -

    [method]tcp-socket.set-send-buffer-size: func

    +

    [method]tcp-socket.set-send-buffer-size: func

    Params
    Return values
    -

    [method]tcp-socket.subscribe: func

    +

    [method]tcp-socket.subscribe: func

    Create a pollable which can be used to poll for, or block on, completion of any of the asynchronous operations of this socket.

    When finish-bind, finish-listen, finish-connect or accept @@ -2799,19 +2798,19 @@ their success or failure, after which the method can be retried.

    in progress at the time of calling subscribe (if any). Theoretically, subscribe only has to be called once per socket and can then be (re)used for the remainder of the socket's lifetime.

    -

    See https://github.com/WebAssembly/wasi-sockets/TcpSocketOperationalSemantics.md#Pollable-readiness -for a more information.

    +

    See https://github.com/WebAssembly/wasi-sockets/blob/main/TcpSocketOperationalSemantics.md#pollable-readiness +for more information.

    Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

    Params
    Return values
    -

    [method]tcp-socket.shutdown: func

    +

    [method]tcp-socket.shutdown: func

    Initiate a graceful shutdown.

    • receive: The socket is not expecting to receive any data from @@ -2822,7 +2821,7 @@ this method will be discarded.
    • associated with this socket will be closed and a FIN packet will be sent.
    • both: Same effect as receive & send combined.
    -

    This function is idempotent. Shutting a down a direction more than once +

    This function is idempotent; shutting down a direction more than once has no effect and returns ok.

    The shutdown function does not close (drop) the socket.

    Typical errors

    @@ -2838,31 +2837,31 @@ has no effect and returns ok.

    Params
    Return values
    -

    Import interface wasi:sockets/tcp-create-socket@0.2.0

    +

    Import interface wasi:sockets/tcp-create-socket@0.2.0


    Types

    -

    type network

    +

    type network

    network

    -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

    -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

    -#### `type tcp-socket` +#### `type tcp-socket` [`tcp-socket`](#tcp_socket)

    ----

    Functions

    -

    create-tcp-socket: func

    +

    create-tcp-socket: func

    Create a new TCP socket.

    Similar to socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP) in POSIX. On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.

    @@ -2884,31 +2883,31 @@ is called, the socket is effectively an in-memory configuration object, unable t
    Params
    Return values
    -

    Import interface wasi:sockets/ip-name-lookup@0.2.0

    +

    Import interface wasi:sockets/ip-name-lookup@0.2.0


    Types

    -

    type pollable

    +

    type pollable

    pollable

    -#### `type network` +#### `type network` [`network`](#network)

    -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

    -#### `type ip-address` +#### `type ip-address` [`ip-address`](#ip_address)

    -#### `resource resolve-address-stream` +#### `resource resolve-address-stream`


    Functions

    -

    resolve-addresses: func

    +

    resolve-addresses: func

    Resolve an internet host name to a list of IP addresses.

    Unicode domain names are automatically converted to ASCII using IDNA encoding. If the input is an IP address string, the address is parsed and returned @@ -2930,14 +2929,14 @@ to (asynchronously) fetch the results.

    Params
    Return values
    -

    [method]resolve-address-stream.resolve-next-address: func

    +

    [method]resolve-address-stream.resolve-next-address: func

    Returns the next address from the resolver.

    This function should be called multiple times. On each call, it will return the next address in connection order preference. If all @@ -2952,31 +2951,31 @@ addresses have been exhausted, this function returns none.

    Params
    Return values
    -

    [method]resolve-address-stream.subscribe: func

    +

    [method]resolve-address-stream.subscribe: func

    Create a pollable which will resolve once the stream is ready for I/O.

    Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

    Params
    Return values
    -

    Import interface wasi:random/random@0.2.0

    +

    Import interface wasi:random/random@0.2.0

    WASI Random is a random data API.

    It is intended to be portable at least between Unix-family platforms and Windows.


    Functions

    -

    get-random-bytes: func

    +

    get-random-bytes: func

    Return len cryptographically-secure random or pseudo-random bytes.

    This function must produce data at least as cryptographically secure and fast as an adequately seeded cryptographically-secure pseudo-random @@ -2989,13 +2988,13 @@ must omit this function, rather than implementing it with deterministic data.

    Params
      -
    • len: u64
    • +
    • len: u64
    Return values
    • list<u8>
    -

    get-random-u64: func

    +

    get-random-u64: func

    Return a cryptographically-secure random or pseudo-random u64 value.

    This function returns the same type of data as get-random-bytes, represented as a u64.

    @@ -3003,13 +3002,13 @@ represented as a u64.

    • u64
    -

    Import interface wasi:random/insecure@0.2.0

    +

    Import interface wasi:random/insecure@0.2.0

    The insecure interface for insecure pseudo-random numbers.

    It is intended to be portable at least between Unix-family platforms and Windows.


    Functions

    -

    get-insecure-random-bytes: func

    +

    get-insecure-random-bytes: func

    Return len insecure pseudo-random bytes.

    This function is not cryptographically secure. Do not use it for anything related to security.

    @@ -3018,13 +3017,13 @@ implementations are encouraged to return evenly distributed values with a long period.

    Params
      -
    • len: u64
    • +
    • len: u64
    Return values
    • list<u8>
    -

    get-insecure-random-u64: func

    +

    get-insecure-random-u64: func

    Return an insecure pseudo-random u64 value.

    This function returns the same type of pseudo-random data as get-insecure-random-bytes, represented as a u64.

    @@ -3032,13 +3031,13 @@ a long period.

    • u64
    -

    Import interface wasi:random/insecure-seed@0.2.0

    +

    Import interface wasi:random/insecure-seed@0.2.0

    The insecure-seed interface for seeding hash-map DoS resistance.

    It is intended to be portable at least between Unix-family platforms and Windows.


    Functions

    -

    insecure-seed: func

    +

    insecure-seed: func

    Return a 128-bit value that may contain a pseudo-random value.

    The returned value is not required to be computed from a CSPRNG, and may even be entirely deterministic. Host implementations are encouraged to @@ -3056,10 +3055,10 @@ protection.

    • (u64, u64)
    -

    Export interface wasi:cli/run@0.2.0

    +

    Export interface wasi:cli/run@0.2.0


    Functions

    -

    run: func

    +

    run: func

    Run the program.

    Return values
    + + +

    Import interface wasi:cli/environment@0.2.0


    Functions

    -

    get-environment: func

    +

    get-environment: func

    Get the POSIX-style environment variables.

    Each environment variable is provided as a pair of string variable names and string value.

    @@ -46,49 +46,47 @@ values each time it is called.

    • list<(string, string)>
    -

    get-arguments: func

    +

    get-arguments: func

    Get the POSIX-style arguments to the program.

    Return values
    • list<string>
    -

    initial-cwd: func

    +

    initial-cwd: func

    Return a path that programs should use as their initial current working directory, interpreting . as shorthand for this.

    Return values
    • option<string>
    -

    Import interface wasi:cli/exit@0.2.0

    +

    Import interface wasi:cli/exit@0.2.0


    Functions

    -

    exit: func

    +

    exit: func

    Exit the current instance and any linked instances.

    Params
      -
    • status: result
    • +
    • status: result
    -

    Import interface wasi:io/error@0.2.0

    +

    Import interface wasi:io/error@0.2.0


    Types

    -

    resource error

    +

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

    +offer functions to "downcast" this error into more specific types. For example, +errors returned from streams derived from filesystem types can be described using +the filesystem's own error-code type. This is done using the function +wasi:filesystem/types/filesystem-error-code, which takes a borrow<error> +parameter and returns an 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

    +

    [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! @@ -97,92 +95,95 @@ details. Parsing this string is a major platform-compatibility hazard.

    Params
    Return values
      -
    • string
    • +
    • string
    -

    Import interface wasi:io/poll@0.2.0

    +

    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

    +

    resource pollable

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

    Functions

    -

    [method]pollable.ready: func

    +

    [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
      -
    • bool
    • +
    • bool
    -

    [method]pollable.block: func

    +

    [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: 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.

    +

    This function traps if either:

    +
      +
    • the list is empty, or:
    • +
    • the list contains more elements than can be indexed with a u32 value.
    • +

    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.

    +being ready for I/O.

    Params
    Return values
    • list<u32>
    -

    Import interface wasi:io/streams@0.2.0

    +

    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

    +

    type error

    error

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

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

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

    Variant Cases
    • -

      last-operation-failed: own<error>

      +

      last-operation-failed: own<error>

      The last operation (a write or flush) failed before completion.

      More information is available in the error payload.

    • -

      closed

      +

      closed

      The stream is closed: no more input will be accepted by the stream. A closed output-stream will return this error on all future operations.

    -

    resource input-stream

    +

    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 @@ -190,7 +191,7 @@ 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

    +

    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 @@ -199,7 +200,7 @@ 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

    +

    [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 @@ -223,51 +224,51 @@ 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

    +

    [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

    +

    [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

    +

    [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

    +

    [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. @@ -276,13 +277,13 @@ Implementations may trap if the input-streampollables created with this function are dropped.

    Params
    Return values
    -

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

    +

    [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 @@ -292,13 +293,13 @@ become ready when this function will report at least 1 byte, or an error.

    Params
    Return values
    -

    [method]output-stream.write: func

    +

    [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 @@ -311,14 +312,14 @@ length of less than or equal to n. Otherwise, this function will trap.

    the last call to check-write provided a permit.

    Params
    Return values
    -

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

    +

    [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, @@ -342,14 +343,14 @@ let _ = this.check-write(); // eliding error handling

    Params
    Return values
    -

    [method]output-stream.flush: func

    +

    [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 @@ -360,24 +361,24 @@ 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

    +

    [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

    +

    [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 @@ -388,13 +389,13 @@ Implementations may trap if the output-streampollables created with this function are dropped.

    Params
    Return values
    -

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

    +

    [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 @@ -402,14 +403,14 @@ 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

    +

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

    @@ -433,14 +434,14 @@ let _ = this.check-write(); // eliding error handling
    Params
    Return values
    -

    [method]output-stream.splice: func

    +

    [method]output-stream.splice: func

    Read from one stream and write to another.

    The behavior of splice is equivelant to:

      @@ -455,161 +456,160 @@ let _ = this.check-write(); // eliding error handling than len.

      Params
      Return values
      -

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

      +

      [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:cli/stdin@0.2.0

      +

      Import interface wasi:cli/stdin@0.2.0


      Types

      -

      type input-stream

      +

      type input-stream

      input-stream

      ----

      Functions

      -

      get-stdin: func

      +

      get-stdin: func

      Return values
      -

      Import interface wasi:cli/stdout@0.2.0

      +

      Import interface wasi:cli/stdout@0.2.0


      Types

      -

      type output-stream

      +

      type output-stream

      output-stream

      ----

      Functions

      -

      get-stdout: func

      +

      get-stdout: func

      Return values
      -

      Import interface wasi:cli/stderr@0.2.0

      +

      Import interface wasi:cli/stderr@0.2.0


      Types

      -

      type output-stream

      +

      type output-stream

      output-stream

      ----

      Functions

      -

      get-stderr: func

      +

      get-stderr: func

      Return values
      -

      Import interface wasi:cli/terminal-input@0.2.0

      +

      Import interface wasi:cli/terminal-input@0.2.0

      Terminal input.

      In the future, this may include functions for disabling echoing, disabling input buffering so that keyboard events are sent through immediately, querying supported features, and so on.


      Types

      -

      resource terminal-input

      +

      resource terminal-input

      The input side of a terminal.

      -

      Import interface wasi:cli/terminal-output@0.2.0

      +

      Import interface wasi:cli/terminal-output@0.2.0

      Terminal output.

      In the future, this may include functions for querying the terminal size, being notified of terminal size changes, querying supported features, and so on.


      Types

      -

      resource terminal-output

      +

      resource terminal-output

      The output side of a terminal.

      -

      Import interface wasi:cli/terminal-stdin@0.2.0

      +

      Import interface wasi:cli/terminal-stdin@0.2.0

      An interface providing an optional terminal-input for stdin as a link-time authority.


      Types

      -

      type terminal-input

      +

      type terminal-input

      terminal-input

      ----

      Functions

      -

      get-terminal-stdin: func

      +

      get-terminal-stdin: func

      If stdin is connected to a terminal, return a terminal-input handle allowing further interaction with it.

      Return values
      -

      Import interface wasi:cli/terminal-stdout@0.2.0

      +

      Import interface wasi:cli/terminal-stdout@0.2.0

      An interface providing an optional terminal-output for stdout as a link-time authority.


      Types

      -

      type terminal-output

      +

      type terminal-output

      terminal-output

      ----

      Functions

      -

      get-terminal-stdout: func

      +

      get-terminal-stdout: func

      If stdout is connected to a terminal, return a terminal-output handle allowing further interaction with it.

      Return values
      -

      Import interface wasi:cli/terminal-stderr@0.2.0

      +

      Import interface wasi:cli/terminal-stderr@0.2.0

      An interface providing an optional terminal-output for stderr as a link-time authority.


      Types

      -

      type terminal-output

      +

      type terminal-output

      terminal-output

      ----

      Functions

      -

      get-terminal-stderr: func

      +

      get-terminal-stderr: func

      If stderr is connected to a terminal, return a terminal-output handle allowing further interaction with it.

      Return values
      -

      Import interface wasi:clocks/monotonic-clock@0.2.0

      +

      Import interface wasi:clocks/monotonic-clock@0.2.0

      WASI Monotonic Clock is a clock API intended to let users measure elapsed time.

      It is intended to be portable at least between Unix-family platforms and Windows.

      A monotonic clock is a clock which has an unspecified initial value, and successive reads of the clock will produce non-decreasing values.

      -

      It is intended for measuring elapsed time.


      Types

      -

      type pollable

      +

      type pollable

      pollable

      -#### `type instant` +#### `type instant` `u64`

      An instant in time, in nanoseconds. An instant is relative to an unspecified initial value, and can only be compared to instances from the same monotonic-clock. -

      type duration

      +

      type duration

      u64

      A duration of time, in nanoseconds.


      Functions

      -

      now: func

      +

      now: func

      Read the current value of the clock.

      The clock is monotonic, therefore calling this function repeatedly will produce a sequence of non-decreasing values.

      @@ -617,37 +617,36 @@ produce a sequence of non-decreasing values.

      -

      resolution: func

      +

      resolution: func

      Query the resolution of the clock. Returns the duration of time corresponding to a clock tick.

      Return values
      -

      subscribe-instant: func

      +

      subscribe-instant: func

      Create a pollable which will resolve once the specified instant -occured.

      +has occured.

      Params
      Return values
      -

      subscribe-duration: func

      -

      Create a pollable which will resolve once the given duration has -elapsed, starting at the time at which this function was called. -occured.

      +

      subscribe-duration: func

      +

      Create a pollable that will resolve after the specified duration has +elapsed from the time this function is invoked.

      Params
      Return values
      -

      Import interface wasi:clocks/wall-clock@0.2.0

      +

      Import interface wasi:clocks/wall-clock@0.2.0

      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.

      @@ -660,16 +659,16 @@ monotonic, making it unsuitable for measuring elapsed time.

      It is intended for reporting the current date and time for humans.


      Types

      -

      record datetime

      +

      record datetime

      A time and date in seconds plus nanoseconds.

      Record Fields

      Functions

      -

      now: func

      +

      now: func

      Read the current value of the clock.

      This clock is not monotonic, therefore calling this function repeatedly will not necessarily produce a sequence of non-decreasing values.

      @@ -681,14 +680,14 @@ also known as Unix Time.
    1. datetime
    2. -

      resolution: func

      +

      resolution: func

      Query the resolution of the clock.

      The nanoseconds field of the output is always less than 1000000000.

      Return values
      -

      Import interface wasi:filesystem/types@0.2.0

      +

      Import interface wasi:filesystem/types@0.2.0

      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.

      @@ -708,75 +707,75 @@ underlying filesystem, the function fails with WASI filesystem path resolution.


      Types

      -

      type input-stream

      +

      type input-stream

      input-stream

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

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

      -#### `type datetime` +#### `type datetime` [`datetime`](#datetime)

      -#### `type filesize` +#### `type filesize` `u64`

      File size or length of a region within a file. -

      enum descriptor-type

      +

      enum descriptor-type

      The type of a filesystem object referenced by a descriptor.

      Note: This was called filetype in earlier versions of WASI.

      Enum Cases
      • -

        unknown

        +

        unknown

        The type of the descriptor or file is unknown or is different from any of the other types specified.

      • -

        block-device

        +

        block-device

        The descriptor refers to a block device inode.

      • -

        character-device

        +

        character-device

        The descriptor refers to a character device inode.

      • -

        directory

        +

        directory

        The descriptor refers to a directory inode.

      • -

        fifo

        +

        fifo

        The descriptor refers to a named pipe.

      • -

        symbolic-link

        +

        symbolic-link

        The file refers to a symbolic link inode.

      • -

        regular-file

        +

        regular-file

        The descriptor refers to a regular file inode.

      • -

        socket

        +

        socket

        The descriptor refers to a socket.

      -

      flags descriptor-flags

      +

      flags descriptor-flags

      Descriptor flags.

      Note: This was called fdflags in earlier versions of WASI.

      Flags members
      • -

        read:

        +

        read:

        Read mode: Data can be read.

      • -

        write:

        +

        write:

        Write mode: Data can be written to.

      • -

        file-integrity-sync:

        +

        file-integrity-sync:

        Request that writes be performed according to synchronized I/O file integrity completion. The data stored in the file and the file's metadata are synchronized. This is similar to `O_SYNC` in POSIX. @@ -785,7 +784,7 @@ WASI. At this time, it should be interpreted as a request, and not a requirement.

      • -

        data-integrity-sync:

        +

        data-integrity-sync:

        Request that writes be performed according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. This is similar to `O_DSYNC` in POSIX. @@ -794,7 +793,7 @@ WASI. At this time, it should be interpreted as a request, and not a requirement.

      • -

        requested-write-sync:

        +

        requested-write-sync:

        Requests that reads be performed at the same level of integrety requested for writes. This is similar to `O_RSYNC` in POSIX.

        The precise semantics of this operation have not yet been defined for @@ -802,7 +801,7 @@ WASI. At this time, it should be interpreted as a request, and not a requirement.

      • -

        mutate-directory:

        +

        mutate-directory:

        Mutating directories mode: Directory contents may be mutated.

        When this flag is unset on a descriptor, operations using the descriptor which would create, rename, delete, modify the data or @@ -812,107 +811,107 @@ they would otherwise succeed.

        This may only be set on directories.

      -

      flags path-flags

      +

      flags path-flags

      Flags determining the method of how paths are resolved.

      Flags members
        -
      • symlink-follow:

        As long as the resolved path corresponds to a symbolic link, it is +

      • symlink-follow:

        As long as the resolved path corresponds to a symbolic link, it is expanded.

      -

      flags open-flags

      +

      flags open-flags

      Open flags used by open-at.

      Flags members
      • -

        create:

        +

        create:

        Create file if it does not exist, similar to `O_CREAT` in POSIX.

      • -

        directory:

        +

        directory:

        Fail if not a directory, similar to `O_DIRECTORY` in POSIX.

      • -

        exclusive:

        +

        exclusive:

        Fail if file already exists, similar to `O_EXCL` in POSIX.

      • -

        truncate:

        +

        truncate:

        Truncate file to size 0, similar to `O_TRUNC` in POSIX.

      -

      type link-count

      +

      type link-count

      u64

      Number of hard links to an inode. -

      record descriptor-stat

      +

      record descriptor-stat

      File attributes.

      Note: This was called filestat in earlier versions of WASI.

      Record Fields
      -

      variant new-timestamp

      +

      variant new-timestamp

      When setting a timestamp, this gives the value to set it to.

      Variant Cases
      • -

        no-change

        +

        no-change

        Leave the timestamp set to its previous value.

      • -

        now

        +

        now

        Set the timestamp to the current time of the system clock associated with the filesystem.

      • -

        timestamp: datetime

        +

        timestamp: datetime

        Set the timestamp to the given value.

      -

      record directory-entry

      +

      record directory-entry

      A directory entry.

      Record Fields
      -

      enum error-code

      +

      enum error-code

      Error codes returned by functions, similar to errno in POSIX. Not all of these error codes are returned by the functions provided by this API; some are used in higher-level library layers, and others are provided @@ -920,211 +919,211 @@ merely for alignment with POSIX.

      Enum Cases
      • -

        access

        +

        access

        Permission denied, similar to `EACCES` in POSIX.

      • -

        would-block

        +

        would-block

        Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.

      • -

        already

        +

        already

        Connection already in progress, similar to `EALREADY` in POSIX.

      • -

        bad-descriptor

        +

        bad-descriptor

        Bad descriptor, similar to `EBADF` in POSIX.

      • -

        busy

        +

        busy

        Device or resource busy, similar to `EBUSY` in POSIX.

      • -

        deadlock

        +

        deadlock

        Resource deadlock would occur, similar to `EDEADLK` in POSIX.

      • -

        quota

        +

        quota

        Storage quota exceeded, similar to `EDQUOT` in POSIX.

      • -

        exist

        +

        exist

        File exists, similar to `EEXIST` in POSIX.

      • -

        file-too-large

        +

        file-too-large

        File too large, similar to `EFBIG` in POSIX.

      • -

        illegal-byte-sequence

        +

        illegal-byte-sequence

        Illegal byte sequence, similar to `EILSEQ` in POSIX.

      • -

        in-progress

        +

        in-progress

        Operation in progress, similar to `EINPROGRESS` in POSIX.

      • -

        interrupted

        +

        interrupted

        Interrupted function, similar to `EINTR` in POSIX.

      • -

        invalid

        +

        invalid

        Invalid argument, similar to `EINVAL` in POSIX.

      • -

        io

        +

        io

        I/O error, similar to `EIO` in POSIX.

      • -

        is-directory

        +

        is-directory

        Is a directory, similar to `EISDIR` in POSIX.

      • -

        loop

        +

        loop

        Too many levels of symbolic links, similar to `ELOOP` in POSIX.

      • -

        too-many-links

        +

        too-many-links

        Too many links, similar to `EMLINK` in POSIX.

      • -

        message-size

        +

        message-size

        Message too large, similar to `EMSGSIZE` in POSIX.

      • -

        name-too-long

        +

        name-too-long

        Filename too long, similar to `ENAMETOOLONG` in POSIX.

      • -

        no-device

        +

        no-device

        No such device, similar to `ENODEV` in POSIX.

      • -

        no-entry

        +

        no-entry

        No such file or directory, similar to `ENOENT` in POSIX.

      • -

        no-lock

        +

        no-lock

        No locks available, similar to `ENOLCK` in POSIX.

      • -

        insufficient-memory

        +

        insufficient-memory

        Not enough space, similar to `ENOMEM` in POSIX.

      • -

        insufficient-space

        +

        insufficient-space

        No space left on device, similar to `ENOSPC` in POSIX.

      • -

        not-directory

        +

        not-directory

        Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.

      • -

        not-empty

        +

        not-empty

        Directory not empty, similar to `ENOTEMPTY` in POSIX.

      • -

        not-recoverable

        +

        not-recoverable

        State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.

      • -

        unsupported

        +

        unsupported

        Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.

      • -

        no-tty

        +

        no-tty

        Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.

      • -

        no-such-device

        +

        no-such-device

        No such device or address, similar to `ENXIO` in POSIX.

      • -

        overflow

        +

        overflow

        Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.

      • -

        not-permitted

        +

        not-permitted

        Operation not permitted, similar to `EPERM` in POSIX.

      • -

        pipe

        +

        pipe

        Broken pipe, similar to `EPIPE` in POSIX.

      • -

        read-only

        +

        read-only

        Read-only file system, similar to `EROFS` in POSIX.

      • -

        invalid-seek

        +

        invalid-seek

        Invalid seek, similar to `ESPIPE` in POSIX.

      • -

        text-file-busy

        +

        text-file-busy

        Text file busy, similar to `ETXTBSY` in POSIX.

      • -

        cross-device

        +

        cross-device

        Cross-device link, similar to `EXDEV` in POSIX.

      -

      enum advice

      +

      enum advice

      File or memory access pattern advisory information.

      Enum Cases
      • -

        normal

        +

        normal

        The application has no advice to give on its behavior with respect to the specified data.

      • -

        sequential

        +

        sequential

        The application expects to access the specified data sequentially from lower offsets to higher offsets.

      • -

        random

        +

        random

        The application expects to access the specified data in a random order.

      • -

        will-need

        +

        will-need

        The application expects to access the specified data in the near future.

      • -

        dont-need

        +

        dont-need

        The application expects that it will not access the specified data in the near future.

      • -

        no-reuse

        +

        no-reuse

        The application expects to access the specified data once and then not reuse it thereafter.

      -

      record metadata-hash-value

      +

      record metadata-hash-value

      A 128-bit hash value, split into parts because wasm doesn't have a 128-bit integer type.

      Record Fields
      • -

        lower: u64

        +

        lower: u64

        64 bits of a 128-bit hash value.

      • -

        upper: u64

        +

        upper: u64

        Another 64 bits of a 128-bit hash value.

      -

      resource descriptor

      +

      resource descriptor

      A descriptor is a reference to a filesystem object, which may be a file, directory, named pipe, special file, or other object on which filesystem calls may be made.

      -

      resource directory-entry-stream

      +

      resource directory-entry-stream

      A stream of directory entries.

      Functions

      -

      [method]descriptor.read-via-stream: func

      +

      [method]descriptor.read-via-stream: func

      Return a stream for reading from a file, if available.

      May fail with an error-code describing why the file cannot be read.

      Multiple read, write, and append streams may be active on the same open @@ -1132,81 +1131,81 @@ file and they do not interfere with each other.

      Note: This allows using read-stream, which is similar to read in POSIX.

      Params
      Return values
      -

      [method]descriptor.write-via-stream: func

      +

      [method]descriptor.write-via-stream: func

      Return a stream for writing to a file, if available.

      May fail with an error-code describing why the file cannot be written.

      Note: This allows using write-stream, which is similar to write in POSIX.

      Params
      Return values
      -

      [method]descriptor.append-via-stream: func

      +

      [method]descriptor.append-via-stream: func

      Return a stream for appending to a file, if available.

      May fail with an error-code describing why the file cannot be appended.

      Note: This allows using write-stream, which is similar to write with O_APPEND in in POSIX.

      Params
      Return values
      -

      [method]descriptor.advise: func

      +

      [method]descriptor.advise: func

      Provide file advisory information on a descriptor.

      This is similar to posix_fadvise in POSIX.

      Params
      Return values
      -

      [method]descriptor.sync-data: func

      +

      [method]descriptor.sync-data: func

      Synchronize the data of a file to disk.

      This function succeeds with no effect if the file descriptor is not opened for writing.

      Note: This is similar to fdatasync in POSIX.

      Params
      Return values
      -

      [method]descriptor.get-flags: func

      +

      [method]descriptor.get-flags: func

      Get flags associated with a descriptor.

      Note: This returns similar flags to fcntl(fd, F_GETFL) in POSIX.

      Note: This returns the value that was the fs_flags value returned from fdstat_get in earlier versions of WASI.

      Params
      Return values
      -

      [method]descriptor.get-type: func

      +

      [method]descriptor.get-type: func

      Get the dynamic type of a descriptor.

      Note: This returns the same value as the type field of the fd-stat returned by stat, stat-at and similar.

      @@ -1216,40 +1215,40 @@ by fstat in POSIX.

      from fdstat_get in earlier versions of WASI.

      Params
      Return values
      -

      [method]descriptor.set-size: func

      +

      [method]descriptor.set-size: func

      Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros.

      Note: This was called fd_filestat_set_size in earlier versions of WASI.

      Params
      Return values
      -

      [method]descriptor.set-times: func

      +

      [method]descriptor.set-times: func

      Adjust the timestamps of an open file or directory.

      Note: This is similar to futimens in POSIX.

      Note: This was called fd_filestat_set_times in earlier versions of WASI.

      Params
      Return values
      -

      [method]descriptor.read: func

      +

      [method]descriptor.read: func

      Read from a descriptor, without using and updating the descriptor's offset.

      This function returns a list of bytes containing the data that was read, along with a bool which, when true, indicates that the end of the @@ -1260,15 +1259,15 @@ if the I/O operation is interrupted.

      Note: This is similar to pread in POSIX.

      Params
      Return values
      -

      [method]descriptor.write: func

      +

      [method]descriptor.write: func

      Write to a descriptor, without using and updating the descriptor's offset.

      It is valid to write past the end of a file; the file is extended to the extent of the write, with bytes between the previous end and the start of @@ -1277,15 +1276,15 @@ the write set to zero.

      Note: This is similar to pwrite in POSIX.

      Params
      Return values
      -

      [method]descriptor.read-directory: func

      +

      [method]descriptor.read-directory: func

      Read directory entries from a directory.

      On filesystems where directories contain entries referring to themselves and their parents, often named . and .. respectively, these entries @@ -1295,38 +1294,38 @@ directory. Multiple streams may be active on the same directory, and they do not interfere with each other.

      Params
      Return values
      -

      [method]descriptor.sync: func

      +

      [method]descriptor.sync: func

      Synchronize the data and metadata of a file to disk.

      This function succeeds with no effect if the file descriptor is not opened for writing.

      Note: This is similar to fsync in POSIX.

      Params
      Return values
      -

      [method]descriptor.create-directory-at: func

      +

      [method]descriptor.create-directory-at: func

      Create a directory.

      Note: This is similar to mkdirat in POSIX.

      Params
      Return values
      -

      [method]descriptor.stat: func

      +

      [method]descriptor.stat: func

      Return the attributes of an open file or directory.

      Note: This is similar to fstat in POSIX, except that it does not return device and inode information. For testing whether two descriptors refer to @@ -1336,13 +1335,13 @@ modified, use metadata-hash.

      Note: This was called fd_filestat_get in earlier versions of WASI.

      Params
      Return values
      -

      [method]descriptor.stat-at: func

      +

      [method]descriptor.stat-at: func

      Return the attributes of a file or directory.

      Note: This is similar to fstatat in POSIX, except that it does not return device and inode information. See the stat description for a @@ -1350,47 +1349,47 @@ discussion of alternatives.

      Note: This was called path_filestat_get in earlier versions of WASI.

      Params
      Return values
      -

      [method]descriptor.set-times-at: func

      +

      [method]descriptor.set-times-at: func

      Adjust the timestamps of a file or directory.

      Note: This is similar to utimensat in POSIX.

      Note: This was called path_filestat_set_times in earlier versions of WASI.

      Params
      Return values
      -

      [method]descriptor.link-at: func

      +

      [method]descriptor.link-at: func

      Create a hard link.

      Note: This is similar to linkat in POSIX.

      Params
      Return values
      -

      [method]descriptor.open-at: func

      +

      [method]descriptor.open-at: func

      Open a file or directory.

      The returned descriptor is not guaranteed to be the lowest-numbered descriptor not currently open/ it is randomized to prevent applications @@ -1407,86 +1406,86 @@ contains truncate or create, and the base descriptor d

      Note: This is similar to openat in POSIX.

      Params
      Return values
      -

      [method]descriptor.readlink-at: func

      +

      [method]descriptor.readlink-at: func

      Read the contents of a symbolic link.

      If the contents contain an absolute or rooted path in the underlying filesystem, this function fails with error-code::not-permitted.

      Note: This is similar to readlinkat in POSIX.

      Params
      Return values
      -

      [method]descriptor.remove-directory-at: func

      +

      [method]descriptor.remove-directory-at: func

      Remove a directory.

      Return error-code::not-empty if the directory is not empty.

      Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.

      Params
      Return values
      -

      [method]descriptor.rename-at: func

      +

      [method]descriptor.rename-at: func

      Rename a filesystem object.

      Note: This is similar to renameat in POSIX.

      Params
      Return values
      -

      [method]descriptor.symlink-at: func

      +

      [method]descriptor.symlink-at: func

      Create a symbolic link (also known as a "symlink").

      If old-path starts with /, the function fails with error-code::not-permitted.

      Note: This is similar to symlinkat in POSIX.

      Params
      Return values
      -

      [method]descriptor.unlink-file-at: func

      +

      [method]descriptor.unlink-file-at: func

      Unlink a filesystem object that is not a directory.

      Return error-code::is-directory if the path refers to a directory. Note: This is similar to unlinkat(fd, path, 0) in POSIX.

      Params
      Return values
      -

      [method]descriptor.is-same-object: func

      +

      [method]descriptor.is-same-object: func

      Test whether two descriptors refer to the same filesystem object.

      In POSIX, this corresponds to testing whether the two descriptors have the same device (st_dev) and inode (st_ino or d_ino) numbers. @@ -1494,14 +1493,14 @@ wasi-filesystem does not expose device and inode numbers, so this function may be used instead.

      Params
      Return values
        -
      • bool
      • +
      • bool
      -

      [method]descriptor.metadata-hash: func

      +

      [method]descriptor.metadata-hash: func

      Return a hash of the metadata associated with a filesystem object referred to by a descriptor.

      This returns a hash of the last-modification timestamp and file size, and @@ -1521,37 +1520,37 @@ computed hash.

      However, none of these is required.

      Params
      Return values
      -

      [method]descriptor.metadata-hash-at: func

      +

      [method]descriptor.metadata-hash-at: func

      Return a hash of the metadata associated with a filesystem object referred to by a directory descriptor and a relative path.

      This performs the same hash computation as metadata-hash.

      Params
      Return values
      -

      [method]directory-entry-stream.read-directory-entry: func

      +

      [method]directory-entry-stream.read-directory-entry: func

      Read a single directory entry from a directory-entry-stream.

      Params
      Return values
      -

      filesystem-error-code: func

      +

      filesystem-error-code: func

      Attempts to extract a filesystem-related error-code from the stream error provided.

      Stream operations which return stream-error::last-operation-failed @@ -1562,34 +1561,34 @@ filesystem-related information about the error to return.

      errors are filesystem-related errors.

      Params
      Return values
      -

      Import interface wasi:filesystem/preopens@0.2.0

      +

      Import interface wasi:filesystem/preopens@0.2.0


      Types

      -

      type descriptor

      +

      type descriptor

      descriptor

      ----

      Functions

      -

      get-directories: func

      +

      get-directories: func

      Return the set of preopened directories, and their path.

      Return values
      -

      Import interface wasi:sockets/network@0.2.0

      +

      Import interface wasi:sockets/network@0.2.0


      Types

      -

      resource network

      +

      resource network

      An opaque resource that represents access to (a subset of) the network. This enables context-based security for networking. There is no need for this to map 1:1 to a physical network interface.

      -

      enum error-code

      +

      enum error-code

      Error codes.

      In theory, every API can return any error code. In practice, API's typically only return the errors documented per API @@ -1605,235 +1604,235 @@ combined with a couple of errors that are always possible:

      Enum Cases
      • -

        unknown

        +

        unknown

        Unknown error

      • -

        access-denied

        +

        access-denied

        Access denied.

        POSIX equivalent: EACCES, EPERM

      • -

        not-supported

        +

        not-supported

        The operation is not supported.

        POSIX equivalent: EOPNOTSUPP

      • -

        invalid-argument

        +

        invalid-argument

        One of the arguments is invalid.

        POSIX equivalent: EINVAL

      • -

        out-of-memory

        +

        out-of-memory

        Not enough memory to complete the operation.

        POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY

      • -

        timeout

        +

        timeout

        The operation timed out before it could finish completely.

      • -

        concurrency-conflict

        +

        concurrency-conflict

        This operation is incompatible with another asynchronous operation that is already in progress.

        POSIX equivalent: EALREADY

      • -

        not-in-progress

        +

        not-in-progress

        Trying to finish an asynchronous operation that: - has not been started yet, or: - was already finished by a previous `finish-*` call.

        Note: this is scheduled to be removed when futures are natively supported.

      • -

        would-block

        +

        would-block

        The operation has been aborted because it could not be completed immediately.

        Note: this is scheduled to be removed when futures are natively supported.

      • -

        invalid-state

        +

        invalid-state

        The operation is not valid in the socket's current state.

      • -

        new-socket-limit

        +

        new-socket-limit

        A new socket resource could not be created because of a system limit.

      • -

        address-not-bindable

        +

        address-not-bindable

        A bind operation failed because the provided address is not an address that the `network` can bind to.

      • -

        address-in-use

        +

        address-in-use

        A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.

      • -

        remote-unreachable

        +

        remote-unreachable

        The remote address is not reachable

      • -

        connection-refused

        +

        connection-refused

        The TCP connection was forcefully rejected

      • -

        connection-reset

        +

        connection-reset

        The TCP connection was reset.

      • -

        connection-aborted

        +

        connection-aborted

        A TCP connection was aborted.

      • -

        datagram-too-large

        +

        datagram-too-large

        The size of a datagram sent to a UDP socket exceeded the maximum supported size.

      • -

        name-unresolvable

        +

        name-unresolvable

        Name does not exist or has no suitable associated IP addresses.

      • -

        temporary-resolver-failure

        +

        temporary-resolver-failure

        A temporary failure in name resolution occurred.

      • -

        permanent-resolver-failure

        +

        permanent-resolver-failure

        A permanent failure in name resolution occurred.

      -

      enum ip-address-family

      +

      enum ip-address-family

      Enum Cases
      • -

        ipv4

        +

        ipv4

        Similar to `AF_INET` in POSIX.

      • -

        ipv6

        +

        ipv6

        Similar to `AF_INET6` in POSIX.

      -

      tuple ipv4-address

      +

      tuple ipv4-address

      Tuple Fields
        -
      • 0: u8
      • -
      • 1: u8
      • -
      • 2: u8
      • -
      • 3: u8
      • +
      • 0: u8
      • +
      • 1: u8
      • +
      • 2: u8
      • +
      • 3: u8
      -

      tuple ipv6-address

      +

      tuple ipv6-address

      Tuple Fields
        -
      • 0: u16
      • -
      • 1: u16
      • -
      • 2: u16
      • -
      • 3: u16
      • -
      • 4: u16
      • -
      • 5: u16
      • -
      • 6: u16
      • -
      • 7: u16
      • +
      • 0: u16
      • +
      • 1: u16
      • +
      • 2: u16
      • +
      • 3: u16
      • +
      • 4: u16
      • +
      • 5: u16
      • +
      • 6: u16
      • +
      • 7: u16
      -

      variant ip-address

      +

      variant ip-address

      Variant Cases
      -

      record ipv4-socket-address

      +

      record ipv4-socket-address

      Record Fields
      -

      record ipv6-socket-address

      +

      record ipv6-socket-address

      Record Fields
      -

      variant ip-socket-address

      +

      variant ip-socket-address

      Variant Cases
      -

      Import interface wasi:sockets/instance-network@0.2.0

      +

      Import interface wasi:sockets/instance-network@0.2.0

      This interface provides a value-export of the default network handle..


      Types

      -

      type network

      +

      type network

      network

      ----

      Functions

      -

      instance-network: func

      +

      instance-network: func

      Get a handle to the default network.

      Return values
      -

      Import interface wasi:sockets/udp@0.2.0

      +

      Import interface wasi:sockets/udp@0.2.0


      Types

      -

      type pollable

      +

      type pollable

      pollable

      -#### `type network` +#### `type network` [`network`](#network)

      -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

      -#### `type ip-socket-address` +#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)

      -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

      -#### `record incoming-datagram` +#### `record incoming-datagram`

      A received datagram.

      Record Fields
      • -

        data: list<u8>

        +

        data: list<u8>

        The payload.

        Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes.

      • -

        remote-address: ip-socket-address

        +

        remote-address: ip-socket-address

        The source address.

        This field is guaranteed to match the remote address the stream was initialized with, if any.

        Equivalent to the src_addr out parameter of recvfrom.

      -

      record outgoing-datagram

      +

      record outgoing-datagram

      A datagram to be sent out.

      Record Fields
      • -

        data: list<u8>

        +

        data: list<u8>

        The payload.

      • -

        remote-address: option<ip-socket-address>

        +

        remote-address: option<ip-socket-address>

        The destination address.

        The requirements on this field depend on how the stream was initialized:

          @@ -1843,13 +1842,13 @@ supported size.

          If this value is None, the send operation is equivalent to send in POSIX. Otherwise it is equivalent to sendto.

        -

        resource udp-socket

        +

        resource udp-socket

        A UDP socket handle.

        -

        resource incoming-datagram-stream

        -

        resource outgoing-datagram-stream

        +

        resource incoming-datagram-stream

        +

        resource outgoing-datagram-stream


        Functions

        -

        [method]udp-socket.start-bind: func

        +

        [method]udp-socket.start-bind: func

        Bind the socket to a specific network on the provided IP address and port.

        If the IP address is zero (0.0.0.0 in IPv4, :: in IPv6), it is left to the implementation to decide which network interface(s) to bind to. @@ -1878,24 +1877,24 @@ don't want to make use of this ability can simply call the native

      Params
      Return values
      -

      [method]udp-socket.finish-bind: func

      +

      [method]udp-socket.finish-bind: func

      Params
      Return values
      -

      [method]udp-socket.stream: func

      +

      [method]udp-socket.stream: func

      Set up inbound & outbound communication channels, optionally to a specific peer.

      This function only changes the local socket configuration and does not generate any network traffic. On success, the remote-address of the socket is updated. The local-address may be updated as well, @@ -1936,14 +1935,14 @@ if (remote_address is Some) {

      Params
      Return values
      -

      [method]udp-socket.local-address: func

      +

      [method]udp-socket.local-address: func

      Get the current bound address.

      POSIX mentions:

      @@ -1964,13 +1963,13 @@ stored in the object pointed to by address is unspecified.

      Params
      Return values
      -

      [method]udp-socket.remote-address: func

      +

      [method]udp-socket.remote-address: func

      Get the address the socket is currently streaming to.

      Typical errors

        @@ -1985,24 +1984,24 @@ stored in the object pointed to by address is unspecified.

      Params
      Return values
      -

      [method]udp-socket.address-family: func

      +

      [method]udp-socket.address-family: func

      Whether this is a IPv4 or IPv6 socket.

      Equivalent to the SO_DOMAIN socket option.

      Params
      Return values
      -

      [method]udp-socket.unicast-hop-limit: func

      +

      [method]udp-socket.unicast-hop-limit: func

      Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.

      If the provided value is 0, an invalid-argument error is returned.

      Typical errors

      @@ -2011,23 +2010,23 @@ stored in the object pointed to by address is unspecified.

      Params
      Return values
      -

      [method]udp-socket.set-unicast-hop-limit: func

      +

      [method]udp-socket.set-unicast-hop-limit: func

      Params
      Return values
      -

      [method]udp-socket.receive-buffer-size: func

      +

      [method]udp-socket.receive-buffer-size: func

      The kernel buffer space reserved for sends/receives on this socket.

      If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2039,54 +2038,54 @@ I.e. after setting a value, reading the same setting back may return a different

      Params
      Return values
      -

      [method]udp-socket.set-receive-buffer-size: func

      +

      [method]udp-socket.set-receive-buffer-size: func

      Params
      Return values
      -

      [method]udp-socket.send-buffer-size: func

      +

      [method]udp-socket.send-buffer-size: func

      Params
      Return values
      -

      [method]udp-socket.set-send-buffer-size: func

      +

      [method]udp-socket.set-send-buffer-size: func

      Params
      Return values
      -

      [method]udp-socket.subscribe: func

      +

      [method]udp-socket.subscribe: func

      Create a pollable which will resolve once the socket is ready for I/O.

      Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

      Params
      Return values
      -

      [method]incoming-datagram-stream.receive: func

      +

      [method]incoming-datagram-stream.receive: func

      Receive messages on the socket.

      This function attempts to receive up to max-results datagrams on the socket without blocking. The returned list may contain fewer elements than requested, but never more.

      @@ -2114,26 +2113,26 @@ This function never returns error(would-block).
      Params
      Return values
      -

      [method]incoming-datagram-stream.subscribe: func

      +

      [method]incoming-datagram-stream.subscribe: func

      Create a pollable which will resolve once the stream is ready to receive again.

      Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

      Params
      Return values
      -

      [method]outgoing-datagram-stream.check-send: func

      +

      [method]outgoing-datagram-stream.check-send: func

      Check readiness for sending. This function never blocks.

      Returns the number of datagrams permitted for the next call to send, or an error. Calling send with more datagrams than this function has @@ -2144,13 +2143,13 @@ error.

      Never returns would-block.

      Params
      Return values
      -

      [method]outgoing-datagram-stream.send: func

      +

      [method]outgoing-datagram-stream.send: func

      Send messages on the socket.

      This function attempts to send all provided datagrams on the socket without blocking and returns how many messages were actually sent (or queued for sending). This function never @@ -2185,43 +2184,43 @@ either check-send was not called or datagrams contains

      Params
      Return values
      -

      [method]outgoing-datagram-stream.subscribe: func

      +

      [method]outgoing-datagram-stream.subscribe: func

      Create a pollable which will resolve once the stream is ready to send again.

      Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

      Params
      Return values
      -

      Import interface wasi:sockets/udp-create-socket@0.2.0

      +

      Import interface wasi:sockets/udp-create-socket@0.2.0


      Types

      -

      type network

      +

      type network

      network

      -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

      -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

      -#### `type udp-socket` +#### `type udp-socket` [`udp-socket`](#udp_socket)

      ----

      Functions

      -

      create-udp-socket: func

      +

      create-udp-socket: func

      Create a new UDP socket.

      Similar to socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP) in POSIX. On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.

      @@ -2243,56 +2242,56 @@ the socket is effectively an in-memory configuration object, unable to communica
      Params
      Return values
      -

      Import interface wasi:sockets/tcp@0.2.0

      +

      Import interface wasi:sockets/tcp@0.2.0


      Types

      -

      type input-stream

      +

      type input-stream

      input-stream

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

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

      -#### `type duration` +#### `type duration` [`duration`](#duration)

      -#### `type network` +#### `type network` [`network`](#network)

      -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

      -#### `type ip-socket-address` +#### `type ip-socket-address` [`ip-socket-address`](#ip_socket_address)

      -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

      -#### `enum shutdown-type` +#### `enum shutdown-type`

      Enum Cases
      • -

        receive

        +

        receive

        Similar to `SHUT_RD` in POSIX.

      • -

        send

        +

        send

        Similar to `SHUT_WR` in POSIX.

      • -

        both

        +

        both

        Similar to `SHUT_RDWR` in POSIX.

      -

      resource tcp-socket

      +

      resource tcp-socket

      A TCP socket resource.

      The socket can be in one of the following states:

      Note: Except where explicitly mentioned, whenever this documentation uses the term "bound" without backticks it actually means: in the bound state or higher. @@ -2314,7 +2313,7 @@ the term "bound" without backticks it actually means: in the bou network::error-code type, TCP socket methods may always return error(invalid-state) when in the closed state.

      Functions

      -

      [method]tcp-socket.start-bind: func

      +

      [method]tcp-socket.start-bind: func

      Bind the socket to a specific network on the provided IP address and port.

      If the IP address is zero (0.0.0.0 in IPv4, :: in IPv6), it is left to the implementation to decide which network interface(s) to bind to. @@ -2353,28 +2352,28 @@ don't want to make use of this ability can simply call the native

      Params
      Return values
      -

      [method]tcp-socket.finish-bind: func

      +

      [method]tcp-socket.finish-bind: func

      Params
      Return values
      -

      [method]tcp-socket.start-connect: func

      +

      [method]tcp-socket.start-connect: func

      Connect to a remote endpoint.

      On success:

        -
      • the socket is transitioned into the connection state.
      • +
      • the socket is transitioned into the connected state.
      • a pair of streams is returned that can be used to read & write to the connection

      After a failed connection attempt, the socket will be in the closed @@ -2415,24 +2414,24 @@ the SO_ERROR socket option, in case the poll signaled readiness.

      Params
      Return values
      -

      [method]tcp-socket.finish-connect: func

      +

      [method]tcp-socket.finish-connect: func

      Params
      Return values
      -

      [method]tcp-socket.start-listen: func

      +

      [method]tcp-socket.start-listen: func

      Start listening for new connections.

      Transitions the socket into the listening state.

      Unlike POSIX, the socket must already be explicitly bound.

      @@ -2459,22 +2458,22 @@ don't want to make use of this ability can simply call the native
      Params
      Return values
      -

      [method]tcp-socket.finish-listen: func

      +

      [method]tcp-socket.finish-listen: func

      Params
      Return values
      -

      [method]tcp-socket.accept: func

      +

      [method]tcp-socket.accept: func

      Accept a new client socket.

      The returned socket is bound and in the connected state. The following properties are inherited from the listener socket:

        @@ -2505,13 +2504,13 @@ a pair of streams that can be used to read & write to the connection.

      Params
      Return values
      -

      [method]tcp-socket.local-address: func

      +

      [method]tcp-socket.local-address: func

      Get the bound local address.

      POSIX mentions:

      @@ -2532,13 +2531,13 @@ stored in the object pointed to by address is unspecified.

      Params
      Return values
      -

      [method]tcp-socket.remote-address: func

      +

      [method]tcp-socket.remote-address: func

      Get the remote address.

      Typical errors

        @@ -2553,35 +2552,35 @@ stored in the object pointed to by address is unspecified.

      Params
      Return values
      -

      [method]tcp-socket.is-listening: func

      +

      [method]tcp-socket.is-listening: func

      Whether the socket is in the listening state.

      Equivalent to the SO_ACCEPTCONN socket option.

      Params
      Return values
        -
      • bool
      • +
      • bool
      -

      [method]tcp-socket.address-family: func

      +

      [method]tcp-socket.address-family: func

      Whether this is a IPv4 or IPv6 socket.

      Equivalent to the SO_DOMAIN socket option.

      Params
      Return values
      -

      [method]tcp-socket.set-listen-backlog-size: func

      +

      [method]tcp-socket.set-listen-backlog-size: func

      Hints the desired listen queue size. Implementations are free to ignore this.

      If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded.

      @@ -2593,14 +2592,14 @@ Any other value will never cause an error, but it might be silently clamped and/
      Params
      Return values
      -

      [method]tcp-socket.keep-alive-enabled: func

      +

      [method]tcp-socket.keep-alive-enabled: func

      Enables or disables keepalive.

      The keepalive behavior can be adjusted using:

        @@ -2612,23 +2611,23 @@ These properties can be configured while keep-alive-enabled is fals

        Equivalent to the SO_KEEPALIVE socket option.

        Params
        Return values
        -

        [method]tcp-socket.set-keep-alive-enabled: func

        +

        [method]tcp-socket.set-keep-alive-enabled: func

        Params
        Return values
        -

        [method]tcp-socket.keep-alive-idle-time: func

        +

        [method]tcp-socket.keep-alive-idle-time: func

        Amount of time the connection has to be idle before TCP starts sending keepalive packets.

        If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2640,23 +2639,23 @@ I.e. after setting a value, reading the same setting back may return a different

      Params
      Return values
      -

      [method]tcp-socket.set-keep-alive-idle-time: func

      +

      [method]tcp-socket.set-keep-alive-idle-time: func

      Params
      Return values
      -

      [method]tcp-socket.keep-alive-interval: func

      +

      [method]tcp-socket.keep-alive-interval: func

      The time between keepalive packets.

      If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2668,23 +2667,23 @@ I.e. after setting a value, reading the same setting back may return a different

      Params
      Return values
      -

      [method]tcp-socket.set-keep-alive-interval: func

      +

      [method]tcp-socket.set-keep-alive-interval: func

      Params
      Return values
      -

      [method]tcp-socket.keep-alive-count: func

      +

      [method]tcp-socket.keep-alive-count: func

      The maximum amount of keepalive packets TCP should send before aborting the connection.

      If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2696,23 +2695,23 @@ I.e. after setting a value, reading the same setting back may return a different

      Params
      Return values
      -

      [method]tcp-socket.set-keep-alive-count: func

      +

      [method]tcp-socket.set-keep-alive-count: func

      Params
      Return values
      -

      [method]tcp-socket.hop-limit: func

      +

      [method]tcp-socket.hop-limit: func

      Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options.

      If the provided value is 0, an invalid-argument error is returned.

      Typical errors

      @@ -2721,23 +2720,23 @@ I.e. after setting a value, reading the same setting back may return a different
      Params
      Return values
      -

      [method]tcp-socket.set-hop-limit: func

      +

      [method]tcp-socket.set-hop-limit: func

      Params
      Return values
      -

      [method]tcp-socket.receive-buffer-size: func

      +

      [method]tcp-socket.receive-buffer-size: func

      The kernel buffer space reserved for sends/receives on this socket.

      If the provided value is 0, an invalid-argument error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded. @@ -2749,42 +2748,42 @@ I.e. after setting a value, reading the same setting back may return a different

      Params
      Return values
      -

      [method]tcp-socket.set-receive-buffer-size: func

      +

      [method]tcp-socket.set-receive-buffer-size: func

      Params
      Return values
      -

      [method]tcp-socket.send-buffer-size: func

      +

      [method]tcp-socket.send-buffer-size: func

      Params
      Return values
      -

      [method]tcp-socket.set-send-buffer-size: func

      +

      [method]tcp-socket.set-send-buffer-size: func

      Params
      Return values
      -

      [method]tcp-socket.subscribe: func

      +

      [method]tcp-socket.subscribe: func

      Create a pollable which can be used to poll for, or block on, completion of any of the asynchronous operations of this socket.

      When finish-bind, finish-listen, finish-connect or accept @@ -2794,19 +2793,19 @@ their success or failure, after which the method can be retried.

      in progress at the time of calling subscribe (if any). Theoretically, subscribe only has to be called once per socket and can then be (re)used for the remainder of the socket's lifetime.

      -

      See https://github.com/WebAssembly/wasi-sockets/TcpSocketOperationalSemantics.md#Pollable-readiness -for a more information.

      +

      See https://github.com/WebAssembly/wasi-sockets/blob/main/TcpSocketOperationalSemantics.md#pollable-readiness +for more information.

      Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

      Params
      Return values
      -

      [method]tcp-socket.shutdown: func

      +

      [method]tcp-socket.shutdown: func

      Initiate a graceful shutdown.

      • receive: The socket is not expecting to receive any data from @@ -2817,7 +2816,7 @@ this method will be discarded.
      • associated with this socket will be closed and a FIN packet will be sent.
      • both: Same effect as receive & send combined.
      -

      This function is idempotent. Shutting a down a direction more than once +

      This function is idempotent; shutting down a direction more than once has no effect and returns ok.

      The shutdown function does not close (drop) the socket.

      Typical errors

      @@ -2833,31 +2832,31 @@ has no effect and returns ok.

      Params
      Return values
      -

      Import interface wasi:sockets/tcp-create-socket@0.2.0

      +

      Import interface wasi:sockets/tcp-create-socket@0.2.0


      Types

      -

      type network

      +

      type network

      network

      -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

      -#### `type ip-address-family` +#### `type ip-address-family` [`ip-address-family`](#ip_address_family)

      -#### `type tcp-socket` +#### `type tcp-socket` [`tcp-socket`](#tcp_socket)

      ----

      Functions

      -

      create-tcp-socket: func

      +

      create-tcp-socket: func

      Create a new TCP socket.

      Similar to socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP) in POSIX. On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.

      @@ -2879,31 +2878,31 @@ is called, the socket is effectively an in-memory configuration object, unable t
      Params
      Return values
      -

      Import interface wasi:sockets/ip-name-lookup@0.2.0

      +

      Import interface wasi:sockets/ip-name-lookup@0.2.0


      Types

      -

      type pollable

      +

      type pollable

      pollable

      -#### `type network` +#### `type network` [`network`](#network)

      -#### `type error-code` +#### `type error-code` [`error-code`](#error_code)

      -#### `type ip-address` +#### `type ip-address` [`ip-address`](#ip_address)

      -#### `resource resolve-address-stream` +#### `resource resolve-address-stream`


      Functions

      -

      resolve-addresses: func

      +

      resolve-addresses: func

      Resolve an internet host name to a list of IP addresses.

      Unicode domain names are automatically converted to ASCII using IDNA encoding. If the input is an IP address string, the address is parsed and returned @@ -2925,14 +2924,14 @@ to (asynchronously) fetch the results.

      Params
      Return values
      -

      [method]resolve-address-stream.resolve-next-address: func

      +

      [method]resolve-address-stream.resolve-next-address: func

      Returns the next address from the resolver.

      This function should be called multiple times. On each call, it will return the next address in connection order preference. If all @@ -2947,31 +2946,31 @@ addresses have been exhausted, this function returns none.

      Params
      Return values
      -

      [method]resolve-address-stream.subscribe: func

      +

      [method]resolve-address-stream.subscribe: func

      Create a pollable which will resolve once the stream is ready for I/O.

      Note: this function is here for WASI Preview2 only. It's planned to be removed when future is natively supported in Preview3.

      Params
      Return values
      -

      Import interface wasi:random/random@0.2.0

      +

      Import interface wasi:random/random@0.2.0

      WASI Random is a random data API.

      It is intended to be portable at least between Unix-family platforms and Windows.


      Functions

      -

      get-random-bytes: func

      +

      get-random-bytes: func

      Return len cryptographically-secure random or pseudo-random bytes.

      This function must produce data at least as cryptographically secure and fast as an adequately seeded cryptographically-secure pseudo-random @@ -2984,13 +2983,13 @@ must omit this function, rather than implementing it with deterministic data.

      Params
        -
      • len: u64
      • +
      • len: u64
      Return values
      • list<u8>
      -

      get-random-u64: func

      +

      get-random-u64: func

      Return a cryptographically-secure random or pseudo-random u64 value.

      This function returns the same type of data as get-random-bytes, represented as a u64.

      @@ -2998,13 +2997,13 @@ represented as a u64.

      • u64
      -

      Import interface wasi:random/insecure@0.2.0

      +

      Import interface wasi:random/insecure@0.2.0

      The insecure interface for insecure pseudo-random numbers.

      It is intended to be portable at least between Unix-family platforms and Windows.


      Functions

      -

      get-insecure-random-bytes: func

      +

      get-insecure-random-bytes: func

      Return len insecure pseudo-random bytes.

      This function is not cryptographically secure. Do not use it for anything related to security.

      @@ -3013,13 +3012,13 @@ implementations are encouraged to return evenly distributed values with a long period.

      Params
        -
      • len: u64
      • +
      • len: u64
      Return values
      • list<u8>
      -

      get-insecure-random-u64: func

      +

      get-insecure-random-u64: func

      Return an insecure pseudo-random u64 value.

      This function returns the same type of pseudo-random data as get-insecure-random-bytes, represented as a u64.

      @@ -3027,13 +3026,13 @@ a long period.

      • u64
      -

      Import interface wasi:random/insecure-seed@0.2.0

      +

      Import interface wasi:random/insecure-seed@0.2.0

      The insecure-seed interface for seeding hash-map DoS resistance.

      It is intended to be portable at least between Unix-family platforms and Windows.


      Functions

      -

      insecure-seed: func

      +

      insecure-seed: func

      Return a 128-bit value that may contain a pseudo-random value.

      The returned value is not required to be computed from a CSPRNG, and may even be entirely deterministic. Host implementations are encouraged to diff --git a/wit/command.wit b/wit/command.wit index d8005bd..0fc85e9 100644 --- a/wit/command.wit +++ b/wit/command.wit @@ -1,7 +1,10 @@ package wasi:cli@0.2.0; +@since(version = 0.2.0) world command { + @since(version = 0.2.0) include imports; + @since(version = 0.2.0) export run; } diff --git a/wit/deps.lock b/wit/deps.lock index 704339a..8660c85 100644 --- a/wit/deps.lock +++ b/wit/deps.lock @@ -1,24 +1,24 @@ [clocks] url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz" -sha256 = "468b4d12892fe926b8eb5d398dbf579d566c93231fa44f415440572c695b7613" -sha512 = "e6b53a07221f1413953c9797c68f08b815fdaebf66419bbc1ea3e8b7dece73731062693634731f311a03957b268cf9cc509c518bd15e513c318aa04a8459b93a" +sha256 = "f27a857de70c1b0dfbabda35812a8de1253089623b1a84ddd066183c6ffac5f8" +sha512 = "9df1b0be1e4925f671fda65d433217798404f8e2e4fa60ff8bfdfd257f0b6d212ea350c141f308cf4cc57fb0b44899b14af1f9af97a05dcd6f8ae00a7594de8d" [filesystem] url = "https://github.com/WebAssembly/wasi-filesystem/archive/main.tar.gz" -sha256 = "498c465cfd04587db40f970fff2185daa597d074c20b68a8bcbae558f261499b" -sha512 = "ead452f9b7bfb88593a502ec00d76d4228003d51c40fd0408aebc32d35c94673551b00230d730873361567cc209ec218c41fb4e95bad194268592c49e7964347" +sha256 = "e37bda5e27222621771ba07d2e9daf862a728c31f91024badfc4f9a42c9ae8ee" +sha512 = "81e92f5e4eca0c8f9606f26a1c4eebb3c53a708b57d3f7e7c60e97aa3c18794b72a44c39212de566442e25313b5ccb5b0b7c9070f3600f0c7c584ea9db91e207" [io] url = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz" -sha256 = "7210e5653539a15478f894d4da24cc69d61924cbcba21d2804d69314a88e5a4c" -sha512 = "49184a1b0945a889abd52d25271172ed3dc2db6968fcdddb1bab7ee0081f4a3eeee0977ad2291126a37631c0d86eeea75d822fa8af224c422134500bf9f0f2bb" +sha256 = "f3e976740ed9512674c627c6588864c477a9ff539bb7e55c7b9ceab222399b52" +sha512 = "c785122b4c04e2297e3fa37ae76c149b0a681444da106758cf673023923b69a6b2c65624ffbb6ad31edef02f9fbc677b05c89525f07b1159fe0c997a8c6b1a8f" [random] url = "https://github.com/WebAssembly/wasi-random/archive/main.tar.gz" -sha256 = "7371d03c037d924caba2587fb2e7c5773a0d3c5fcecbf7971e0e0ba57973c53d" -sha512 = "964c4e8925a53078e4d94ba907b54f89a0b7e154f46823a505391471466c17f53c8692682e5c85771712acd88b348686173fc07c53a3cfe3d301b8cd8ddd0de4" +sha256 = "2f0014e946e38947afe120836b17cdcfa608be993d38d55b81cc2d31e7e70b16" +sha512 = "51ee623509040de77b0ba236e29589102538aacd3dd67168b06a09bf6ae469c762818fc07b5039d2a8b1838f4b5a5965a7c81ed0e2d47b142bece9d1ab8b93a6" [sockets] url = "https://github.com/WebAssembly/wasi-sockets/archive/main.tar.gz" -sha256 = "622bd28bbeb43736375dc02bd003fd3a016ff8ee91e14bab488325c6b38bf966" -sha512 = "5a63c1f36de0c4548e1d2297bdbededb28721cbad94ef7825c469eae29d7451c97e00b4c1d6730ee1ec0c4a5aac922961a2795762d4a0c3bb54e30a391a84bae" +sha256 = "5321ba37115d503bfe0880349e99ecbd26ee812708fa83d2b276ec8ee7571443" +sha512 = "c3d71c2afa1475bf10d86b1e0623e2292e5dd407cf54103ad0d05c07fa95323bff9ad06e929d508b318a0a99a67132793fb9a04c17585843e24f090f5ee91367" diff --git a/wit/deps/clocks/monotonic-clock.wit b/wit/deps/clocks/monotonic-clock.wit index 4e4dc3a..cae2363 100644 --- a/wit/deps/clocks/monotonic-clock.wit +++ b/wit/deps/clocks/monotonic-clock.wit @@ -7,38 +7,43 @@ package wasi:clocks@0.2.0; /// /// A monotonic clock is a clock which has an unspecified initial value, and /// successive reads of the clock will produce non-decreasing values. -/// -/// It is intended for measuring elapsed time. +@since(version = 0.2.0) interface monotonic-clock { + @since(version = 0.2.0) use wasi:io/poll@0.2.0.{pollable}; /// An instant in time, in nanoseconds. An instant is relative to an /// unspecified initial value, and can only be compared to instances from /// the same monotonic-clock. + @since(version = 0.2.0) type instant = u64; /// A duration of time, in nanoseconds. + @since(version = 0.2.0) type duration = u64; /// Read the current value of the clock. /// /// The clock is monotonic, therefore calling this function repeatedly will /// produce a sequence of non-decreasing values. + @since(version = 0.2.0) now: func() -> instant; /// Query the resolution of the clock. Returns the duration of time /// corresponding to a clock tick. + @since(version = 0.2.0) resolution: func() -> duration; /// Create a `pollable` which will resolve once the specified instant - /// occured. + /// has occured. + @since(version = 0.2.0) subscribe-instant: func( when: instant, ) -> pollable; - /// Create a `pollable` which will resolve once the given duration has - /// elapsed, starting at the time at which this function was called. - /// occured. + /// Create a `pollable` that will resolve after the specified duration has + /// elapsed from the time this function is invoked. + @since(version = 0.2.0) subscribe-duration: func( when: duration, ) -> pollable; diff --git a/wit/deps/clocks/timezone.wit b/wit/deps/clocks/timezone.wit new file mode 100644 index 0000000..3c28688 --- /dev/null +++ b/wit/deps/clocks/timezone.wit @@ -0,0 +1,55 @@ +package wasi:clocks@0.2.0; + +@unstable(feature = clocks-timezone) +interface timezone { + @unstable(feature = clocks-timezone) + use wall-clock.{datetime}; + + /// Return information needed to display the given `datetime`. This includes + /// the UTC offset, the time zone name, and a flag indicating whether + /// daylight saving time is active. + /// + /// If the timezone cannot be determined for the given `datetime`, return a + /// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight + /// saving time. + @unstable(feature = clocks-timezone) + display: func(when: datetime) -> timezone-display; + + /// The same as `display`, but only return the UTC offset. + @unstable(feature = clocks-timezone) + utc-offset: func(when: datetime) -> s32; + + /// Information useful for displaying the timezone of a specific `datetime`. + /// + /// This information may vary within a single `timezone` to reflect daylight + /// saving time adjustments. + @unstable(feature = clocks-timezone) + record timezone-display { + /// The number of seconds difference between UTC time and the local + /// time of the timezone. + /// + /// The returned value will always be less than 86400 which is the + /// number of seconds in a day (24*60*60). + /// + /// In implementations that do not expose an actual time zone, this + /// should return 0. + utc-offset: s32, + + /// The abbreviated name of the timezone to display to a user. The name + /// `UTC` indicates Coordinated Universal Time. Otherwise, this should + /// reference local standards for the name of the time zone. + /// + /// In implementations that do not expose an actual time zone, this + /// should be the string `UTC`. + /// + /// In time zones that do not have an applicable name, a formatted + /// representation of the UTC offset may be returned, such as `-04:00`. + name: string, + + /// Whether daylight saving time is active. + /// + /// In implementations that do not expose an actual time zone, this + /// should return false. + in-daylight-saving-time: bool, + } +} diff --git a/wit/deps/clocks/wall-clock.wit b/wit/deps/clocks/wall-clock.wit index 440ca0f..4b08d71 100644 --- a/wit/deps/clocks/wall-clock.wit +++ b/wit/deps/clocks/wall-clock.wit @@ -13,8 +13,10 @@ package wasi:clocks@0.2.0; /// monotonic, making it unsuitable for measuring elapsed time. /// /// It is intended for reporting the current date and time for humans. +@since(version = 0.2.0) interface wall-clock { /// A time and date in seconds plus nanoseconds. + @since(version = 0.2.0) record datetime { seconds: u64, nanoseconds: u32, @@ -33,10 +35,12 @@ interface wall-clock { /// /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time + @since(version = 0.2.0) now: func() -> datetime; /// Query the resolution of the clock. /// /// The nanoseconds field of the output is always less than 1000000000. + @since(version = 0.2.0) resolution: func() -> datetime; } diff --git a/wit/deps/clocks/world.wit b/wit/deps/clocks/world.wit index c022457..76a9206 100644 --- a/wit/deps/clocks/world.wit +++ b/wit/deps/clocks/world.wit @@ -1,6 +1,11 @@ package wasi:clocks@0.2.0; +@since(version = 0.2.0) world imports { + @since(version = 0.2.0) import monotonic-clock; + @since(version = 0.2.0) import wall-clock; + @unstable(feature = clocks-timezone) + import timezone; } diff --git a/wit/deps/filesystem/preopens.wit b/wit/deps/filesystem/preopens.wit index da801f6..08094ab 100644 --- a/wit/deps/filesystem/preopens.wit +++ b/wit/deps/filesystem/preopens.wit @@ -1,8 +1,11 @@ package wasi:filesystem@0.2.0; +@since(version = 0.2.0) interface preopens { + @since(version = 0.2.0) use types.{descriptor}; /// Return the set of preopened directories, and their path. + @since(version = 0.2.0) get-directories: func() -> list>; } diff --git a/wit/deps/filesystem/types.wit b/wit/deps/filesystem/types.wit index 11108fc..4900ae2 100644 --- a/wit/deps/filesystem/types.wit +++ b/wit/deps/filesystem/types.wit @@ -23,16 +23,21 @@ package wasi:filesystem@0.2.0; /// [WASI filesystem path resolution]. /// /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md +@since(version = 0.2.0) interface types { + @since(version = 0.2.0) use wasi:io/streams@0.2.0.{input-stream, output-stream, error}; + @since(version = 0.2.0) use wasi:clocks/wall-clock@0.2.0.{datetime}; /// File size or length of a region within a file. + @since(version = 0.2.0) type filesize = u64; /// The type of a filesystem object referenced by a descriptor. /// /// Note: This was called `filetype` in earlier versions of WASI. + @since(version = 0.2.0) enum descriptor-type { /// The type of the descriptor or file is unknown or is different from /// any of the other types specified. @@ -56,6 +61,7 @@ interface types { /// Descriptor flags. /// /// Note: This was called `fdflags` in earlier versions of WASI. + @since(version = 0.2.0) flags descriptor-flags { /// Read mode: Data can be read. read, @@ -99,6 +105,7 @@ interface types { /// File attributes. /// /// Note: This was called `filestat` in earlier versions of WASI. + @since(version = 0.2.0) record descriptor-stat { /// File type. %type: descriptor-type, @@ -125,6 +132,7 @@ interface types { } /// Flags determining the method of how paths are resolved. + @since(version = 0.2.0) flags path-flags { /// As long as the resolved path corresponds to a symbolic link, it is /// expanded. @@ -132,6 +140,7 @@ interface types { } /// Open flags used by `open-at`. + @since(version = 0.2.0) flags open-flags { /// Create file if it does not exist, similar to `O_CREAT` in POSIX. create, @@ -144,9 +153,11 @@ interface types { } /// Number of hard links to an inode. + @since(version = 0.2.0) type link-count = u64; /// When setting a timestamp, this gives the value to set it to. + @since(version = 0.2.0) variant new-timestamp { /// Leave the timestamp set to its previous value. no-change, @@ -248,6 +259,7 @@ interface types { } /// File or memory access pattern advisory information. + @since(version = 0.2.0) enum advice { /// The application has no advice to give on its behavior with respect /// to the specified data. @@ -271,6 +283,7 @@ interface types { /// A 128-bit hash value, split into parts because wasm doesn't have a /// 128-bit integer type. + @since(version = 0.2.0) record metadata-hash-value { /// 64 bits of a 128-bit hash value. lower: u64, @@ -281,6 +294,7 @@ interface types { /// A descriptor is a reference to a filesystem object, which may be a file, /// directory, named pipe, special file, or other object on which filesystem /// calls may be made. + @since(version = 0.2.0) resource descriptor { /// Return a stream for reading from a file, if available. /// @@ -290,6 +304,7 @@ interface types { /// file and they do not interfere with each other. /// /// Note: This allows using `read-stream`, which is similar to `read` in POSIX. + @since(version = 0.2.0) read-via-stream: func( /// The offset within the file at which to start reading. offset: filesize, @@ -301,6 +316,7 @@ interface types { /// /// Note: This allows using `write-stream`, which is similar to `write` in /// POSIX. + @since(version = 0.2.0) write-via-stream: func( /// The offset within the file at which to start writing. offset: filesize, @@ -312,11 +328,13 @@ interface types { /// /// Note: This allows using `write-stream`, which is similar to `write` with /// `O_APPEND` in in POSIX. + @since(version = 0.2.0) append-via-stream: func() -> result; /// Provide file advisory information on a descriptor. /// /// This is similar to `posix_fadvise` in POSIX. + @since(version = 0.2.0) advise: func( /// The offset within the file to which the advisory applies. offset: filesize, @@ -332,6 +350,7 @@ interface types { /// opened for writing. /// /// Note: This is similar to `fdatasync` in POSIX. + @since(version = 0.2.0) sync-data: func() -> result<_, error-code>; /// Get flags associated with a descriptor. @@ -340,6 +359,7 @@ interface types { /// /// Note: This returns the value that was the `fs_flags` value returned /// from `fdstat_get` in earlier versions of WASI. + @since(version = 0.2.0) get-flags: func() -> result; /// Get the dynamic type of a descriptor. @@ -352,12 +372,14 @@ interface types { /// /// Note: This returns the value that was the `fs_filetype` value returned /// from `fdstat_get` in earlier versions of WASI. + @since(version = 0.2.0) get-type: func() -> result; /// Adjust the size of an open file. If this increases the file's size, the /// extra bytes are filled with zeros. /// /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. + @since(version = 0.2.0) set-size: func(size: filesize) -> result<_, error-code>; /// Adjust the timestamps of an open file or directory. @@ -365,6 +387,7 @@ interface types { /// Note: This is similar to `futimens` in POSIX. /// /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. + @since(version = 0.2.0) set-times: func( /// The desired values of the data access timestamp. data-access-timestamp: new-timestamp, @@ -383,6 +406,7 @@ interface types { /// In the future, this may change to return a `stream`. /// /// Note: This is similar to `pread` in POSIX. + @since(version = 0.2.0) read: func( /// The maximum number of bytes to read. length: filesize, @@ -399,6 +423,7 @@ interface types { /// In the future, this may change to take a `stream`. /// /// Note: This is similar to `pwrite` in POSIX. + @since(version = 0.2.0) write: func( /// Data to write buffer: list, @@ -415,6 +440,7 @@ interface types { /// This always returns a new stream which starts at the beginning of the /// directory. Multiple streams may be active on the same directory, and they /// do not interfere with each other. + @since(version = 0.2.0) read-directory: func() -> result; /// Synchronize the data and metadata of a file to disk. @@ -423,11 +449,13 @@ interface types { /// opened for writing. /// /// Note: This is similar to `fsync` in POSIX. + @since(version = 0.2.0) sync: func() -> result<_, error-code>; /// Create a directory. /// /// Note: This is similar to `mkdirat` in POSIX. + @since(version = 0.2.0) create-directory-at: func( /// The relative path at which to create the directory. path: string, @@ -442,6 +470,7 @@ interface types { /// modified, use `metadata-hash`. /// /// Note: This was called `fd_filestat_get` in earlier versions of WASI. + @since(version = 0.2.0) stat: func() -> result; /// Return the attributes of a file or directory. @@ -451,6 +480,7 @@ interface types { /// discussion of alternatives. /// /// Note: This was called `path_filestat_get` in earlier versions of WASI. + @since(version = 0.2.0) stat-at: func( /// Flags determining the method of how the path is resolved. path-flags: path-flags, @@ -464,6 +494,7 @@ interface types { /// /// Note: This was called `path_filestat_set_times` in earlier versions of /// WASI. + @since(version = 0.2.0) set-times-at: func( /// Flags determining the method of how the path is resolved. path-flags: path-flags, @@ -478,6 +509,7 @@ interface types { /// Create a hard link. /// /// Note: This is similar to `linkat` in POSIX. + @since(version = 0.2.0) link-at: func( /// Flags determining the method of how the path is resolved. old-path-flags: path-flags, @@ -507,6 +539,7 @@ interface types { /// `error-code::read-only`. /// /// Note: This is similar to `openat` in POSIX. + @since(version = 0.2.0) open-at: func( /// Flags determining the method of how the path is resolved. path-flags: path-flags, @@ -524,6 +557,7 @@ interface types { /// filesystem, this function fails with `error-code::not-permitted`. /// /// Note: This is similar to `readlinkat` in POSIX. + @since(version = 0.2.0) readlink-at: func( /// The relative path of the symbolic link from which to read. path: string, @@ -534,6 +568,7 @@ interface types { /// Return `error-code::not-empty` if the directory is not empty. /// /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. + @since(version = 0.2.0) remove-directory-at: func( /// The relative path to a directory to remove. path: string, @@ -542,6 +577,7 @@ interface types { /// Rename a filesystem object. /// /// Note: This is similar to `renameat` in POSIX. + @since(version = 0.2.0) rename-at: func( /// The relative source path of the file or directory to rename. old-path: string, @@ -557,6 +593,7 @@ interface types { /// `error-code::not-permitted`. /// /// Note: This is similar to `symlinkat` in POSIX. + @since(version = 0.2.0) symlink-at: func( /// The contents of the symbolic link. old-path: string, @@ -568,6 +605,7 @@ interface types { /// /// Return `error-code::is-directory` if the path refers to a directory. /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. + @since(version = 0.2.0) unlink-file-at: func( /// The relative path to a file to unlink. path: string, @@ -579,6 +617,7 @@ interface types { /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. /// wasi-filesystem does not expose device and inode numbers, so this function /// may be used instead. + @since(version = 0.2.0) is-same-object: func(other: borrow) -> bool; /// Return a hash of the metadata associated with a filesystem object referred @@ -600,12 +639,14 @@ interface types { /// computed hash. /// /// However, none of these is required. + @since(version = 0.2.0) metadata-hash: func() -> result; /// Return a hash of the metadata associated with a filesystem object referred /// to by a directory descriptor and a relative path. /// /// This performs the same hash computation as `metadata-hash`. + @since(version = 0.2.0) metadata-hash-at: func( /// Flags determining the method of how the path is resolved. path-flags: path-flags, @@ -615,8 +656,10 @@ interface types { } /// A stream of directory entries. + @since(version = 0.2.0) resource directory-entry-stream { /// Read a single directory entry from a `directory-entry-stream`. + @since(version = 0.2.0) read-directory-entry: func() -> result, error-code>; } @@ -630,5 +673,6 @@ interface types { /// /// Note that this function is fallible because not all stream-related /// errors are filesystem-related errors. + @since(version = 0.2.0) filesystem-error-code: func(err: borrow) -> option; } diff --git a/wit/deps/filesystem/world.wit b/wit/deps/filesystem/world.wit index 663f579..c8d99f5 100644 --- a/wit/deps/filesystem/world.wit +++ b/wit/deps/filesystem/world.wit @@ -1,6 +1,9 @@ package wasi:filesystem@0.2.0; +@since(version = 0.2.0) world imports { + @since(version = 0.2.0) import types; + @since(version = 0.2.0) import preopens; } diff --git a/wit/deps/io/error.wit b/wit/deps/io/error.wit index 22e5b64..7e66dbb 100644 --- a/wit/deps/io/error.wit +++ b/wit/deps/io/error.wit @@ -1,6 +1,6 @@ package wasi:io@0.2.0; - +@since(version = 0.2.0) interface error { /// A resource which represents some error information. /// @@ -11,16 +11,15 @@ interface error { /// `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, `error`s 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` and returns - /// `option`. + /// offer functions to "downcast" this error into more specific types. For example, + /// errors returned from streams derived from filesystem types can be described using + /// the filesystem's own error-code type. This is done using the function + /// `wasi:filesystem/types/filesystem-error-code`, which takes a `borrow` + /// parameter and returns an `option`. /// /// The set of functions which can "downcast" an `error` into a more /// concrete type is open. + @since(version = 0.2.0) resource error { /// Returns a string that is suitable to assist humans in debugging /// this error. @@ -29,6 +28,7 @@ interface error { /// It may change across platforms, hosts, or other implementation /// details. Parsing this string is a major platform-compatibility /// hazard. + @since(version = 0.2.0) to-debug-string: func() -> string; } } diff --git a/wit/deps/io/poll.wit b/wit/deps/io/poll.wit index ddc67f8..cbdc960 100644 --- a/wit/deps/io/poll.wit +++ b/wit/deps/io/poll.wit @@ -2,13 +2,16 @@ package wasi:io@0.2.0; /// A poll API intended to let users wait for I/O events on multiple handles /// at once. +@since(version = 0.2.0) interface poll { /// `pollable` represents a single I/O event which may be ready, or not. + @since(version = 0.2.0) resource pollable { /// Return the readiness of a pollable. This function never blocks. /// /// Returns `true` when the pollable is ready, and `false` otherwise. + @since(version = 0.2.0) ready: func() -> bool; /// `block` returns immediately if the pollable is ready, and otherwise @@ -16,6 +19,7 @@ interface poll { /// /// This function is equivalent to calling `poll.poll` on a list /// containing only this pollable. + @since(version = 0.2.0) block: func(); } @@ -27,8 +31,9 @@ interface poll { /// The result `list` 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. + /// This function traps if either: + /// - the list is empty, or: + /// - the list contains more elements than can be indexed with a `u32` value. /// /// A timeout can be implemented by adding a pollable from the /// wasi-clocks API to the list. @@ -36,6 +41,7 @@ interface poll { /// 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. + /// being ready for I/O. + @since(version = 0.2.0) poll: func(in: list>) -> list; } diff --git a/wit/deps/io/streams.wit b/wit/deps/io/streams.wit index 6d2f871..a57f204 100644 --- a/wit/deps/io/streams.wit +++ b/wit/deps/io/streams.wit @@ -5,11 +5,15 @@ package wasi:io@0.2.0; /// /// In the future, the component model is expected to add built-in stream types; /// when it does, they are expected to subsume this API. +@since(version = 0.2.0) interface streams { + @since(version = 0.2.0) use error.{error}; + @since(version = 0.2.0) use poll.{pollable}; /// An error for input-stream and output-stream operations. + @since(version = 0.2.0) variant stream-error { /// The last operation (a write or flush) failed before completion. /// @@ -29,6 +33,7 @@ interface streams { /// 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`. + @since(version = 0.2.0) resource input-stream { /// Perform a non-blocking read from the stream. /// @@ -56,6 +61,7 @@ interface streams { /// 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. + @since(version = 0.2.0) read: func( /// The maximum number of bytes to read len: u64 @@ -63,6 +69,7 @@ interface streams { /// Read bytes from a stream, after blocking until at least one byte can /// be read. Except for blocking, behavior is identical to `read`. + @since(version = 0.2.0) blocking-read: func( /// The maximum number of bytes to read len: u64 @@ -72,6 +79,7 @@ interface streams { /// /// Behaves identical to `read`, except instead of returning a list /// of bytes, returns the number of bytes consumed from the stream. + @since(version = 0.2.0) skip: func( /// The maximum number of bytes to skip. len: u64, @@ -79,6 +87,7 @@ interface streams { /// Skip bytes from a stream, after blocking until at least one byte /// can be skipped. Except for blocking behavior, identical to `skip`. + @since(version = 0.2.0) blocking-skip: func( /// The maximum number of bytes to skip. len: u64, @@ -90,6 +99,7 @@ interface streams { /// The created `pollable` is a child resource of the `input-stream`. /// Implementations may trap if the `input-stream` is dropped before /// all derived `pollable`s created with this function are dropped. + @since(version = 0.2.0) subscribe: func() -> pollable; } @@ -102,6 +112,7 @@ interface streams { /// 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`. + @since(version = 0.2.0) resource output-stream { /// Check readiness for writing. This function never blocks. /// @@ -112,6 +123,7 @@ interface streams { /// When this function returns 0 bytes, the `subscribe` pollable will /// become ready when this function will report at least 1 byte, or an /// error. + @since(version = 0.2.0) check-write: func() -> result; /// Perform a write. This function never blocks. @@ -127,6 +139,7 @@ interface streams { /// /// returns Err(closed) without writing if the stream has closed since /// the last call to check-write provided a permit. + @since(version = 0.2.0) write: func( contents: list ) -> result<_, stream-error>; @@ -155,6 +168,7 @@ interface streams { /// // Check for any errors that arose during `flush` /// let _ = this.check-write(); // eliding error handling /// ``` + @since(version = 0.2.0) blocking-write-and-flush: func( contents: list ) -> result<_, stream-error>; @@ -169,10 +183,12 @@ interface streams { /// 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. + @since(version = 0.2.0) flush: func() -> result<_, stream-error>; /// Request to flush buffered output, and block until flush completes /// and stream is ready for writing again. + @since(version = 0.2.0) blocking-flush: func() -> result<_, stream-error>; /// Create a `pollable` which will resolve once the output-stream @@ -193,6 +209,7 @@ interface streams { /// 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. + @since(version = 0.2.0) write-zeroes: func( /// The number of zero-bytes to write len: u64 @@ -222,6 +239,7 @@ interface streams { /// // Check for any errors that arose during `flush` /// let _ = this.check-write(); // eliding error handling /// ``` + @since(version = 0.2.0) blocking-write-zeroes-and-flush: func( /// The number of zero-bytes to write len: u64 @@ -240,6 +258,7 @@ interface streams { /// /// This function returns the number of bytes transferred; it may be less /// than `len`. + @since(version = 0.2.0) splice: func( /// The stream to read from src: borrow, @@ -252,6 +271,7 @@ interface streams { /// 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`. + @since(version = 0.2.0) blocking-splice: func( /// The stream to read from src: borrow, diff --git a/wit/deps/io/world.wit b/wit/deps/io/world.wit index 5f0b43f..f5c0987 100644 --- a/wit/deps/io/world.wit +++ b/wit/deps/io/world.wit @@ -1,6 +1,10 @@ package wasi:io@0.2.0; +@since(version = 0.2.0) world imports { + @since(version = 0.2.0) import streams; + + @since(version = 0.2.0) import poll; } diff --git a/wit/deps/random/insecure-seed.wit b/wit/deps/random/insecure-seed.wit index 47210ac..4cce628 100644 --- a/wit/deps/random/insecure-seed.wit +++ b/wit/deps/random/insecure-seed.wit @@ -3,6 +3,7 @@ package wasi:random@0.2.0; /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. +@since(version = 0.2.0) interface insecure-seed { /// Return a 128-bit value that may contain a pseudo-random value. /// @@ -21,5 +22,6 @@ interface insecure-seed { /// This will likely be changed to a value import, to prevent it from being /// called multiple times and potentially used for purposes other than DoS /// protection. + @since(version = 0.2.0) insecure-seed: func() -> tuple; } diff --git a/wit/deps/random/insecure.wit b/wit/deps/random/insecure.wit index c58f4ee..3cea0c4 100644 --- a/wit/deps/random/insecure.wit +++ b/wit/deps/random/insecure.wit @@ -3,6 +3,7 @@ package wasi:random@0.2.0; /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. +@since(version = 0.2.0) interface insecure { /// Return `len` insecure pseudo-random bytes. /// @@ -12,11 +13,13 @@ interface insecure { /// There are no requirements on the values of the returned bytes, however /// implementations are encouraged to return evenly distributed values with /// a long period. + @since(version = 0.2.0) get-insecure-random-bytes: func(len: u64) -> list; /// Return an insecure pseudo-random `u64` value. /// /// This function returns the same type of pseudo-random data as /// `get-insecure-random-bytes`, represented as a `u64`. + @since(version = 0.2.0) get-insecure-random-u64: func() -> u64; } diff --git a/wit/deps/random/random.wit b/wit/deps/random/random.wit index 0c017f0..41c3a03 100644 --- a/wit/deps/random/random.wit +++ b/wit/deps/random/random.wit @@ -3,6 +3,7 @@ package wasi:random@0.2.0; /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. +@since(version = 0.2.0) interface random { /// Return `len` cryptographically-secure random or pseudo-random bytes. /// @@ -16,11 +17,13 @@ interface random { /// This function must always return fresh data. Deterministic environments /// must omit this function, rather than implementing it with deterministic /// data. + @since(version = 0.2.0) get-random-bytes: func(len: u64) -> list; /// Return a cryptographically-secure random or pseudo-random `u64` value. /// /// This function returns the same type of data as `get-random-bytes`, /// represented as a `u64`. + @since(version = 0.2.0) get-random-u64: func() -> u64; } diff --git a/wit/deps/random/world.wit b/wit/deps/random/world.wit index 3da3491..b5560a6 100644 --- a/wit/deps/random/world.wit +++ b/wit/deps/random/world.wit @@ -1,7 +1,13 @@ package wasi:random@0.2.0; +@since(version = 0.2.0) world imports { + @since(version = 0.2.0) import random; + + @since(version = 0.2.0) import insecure; + + @since(version = 0.2.0) import insecure-seed; } diff --git a/wit/deps/sockets/instance-network.wit b/wit/deps/sockets/instance-network.wit index e455d0f..5f6e6c1 100644 --- a/wit/deps/sockets/instance-network.wit +++ b/wit/deps/sockets/instance-network.wit @@ -1,9 +1,11 @@ /// This interface provides a value-export of the default network handle.. +@since(version = 0.2.0) interface instance-network { + @since(version = 0.2.0) use network.{network}; /// Get a handle to the default network. + @since(version = 0.2.0) instance-network: func() -> network; - } diff --git a/wit/deps/sockets/ip-name-lookup.wit b/wit/deps/sockets/ip-name-lookup.wit index 8e639ec..0368b48 100644 --- a/wit/deps/sockets/ip-name-lookup.wit +++ b/wit/deps/sockets/ip-name-lookup.wit @@ -1,9 +1,10 @@ - +@since(version = 0.2.0) interface ip-name-lookup { + @since(version = 0.2.0) use wasi:io/poll@0.2.0.{pollable}; + @since(version = 0.2.0) use network.{network, error-code, ip-address}; - /// Resolve an internet host name to a list of IP addresses. /// /// Unicode domain names are automatically converted to ASCII using IDNA encoding. @@ -24,8 +25,10 @@ interface ip-name-lookup { /// - /// - /// - + @since(version = 0.2.0) resolve-addresses: func(network: borrow, name: string) -> result; + @since(version = 0.2.0) resource resolve-address-stream { /// Returns the next address from the resolver. /// @@ -40,12 +43,14 @@ interface ip-name-lookup { /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) + @since(version = 0.2.0) resolve-next-address: func() -> result, error-code>; /// Create a `pollable` which will resolve once the stream is ready for I/O. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; } } diff --git a/wit/deps/sockets/network.wit b/wit/deps/sockets/network.wit index 9cadf06..8c13b34 100644 --- a/wit/deps/sockets/network.wit +++ b/wit/deps/sockets/network.wit @@ -1,8 +1,9 @@ - +@since(version = 0.2.0) interface network { /// An opaque resource that represents access to (a subset of) the network. /// This enables context-based security for networking. /// There is no need for this to map 1:1 to a physical network interface. + @since(version = 0.2.0) resource network; /// Error codes. @@ -17,6 +18,7 @@ interface network { /// - `concurrency-conflict` /// /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. + @since(version = 0.2.0) enum error-code { /// Unknown error unknown, @@ -103,6 +105,7 @@ interface network { permanent-resolver-failure, } + @since(version = 0.2.0) enum ip-address-family { /// Similar to `AF_INET` in POSIX. ipv4, @@ -111,14 +114,18 @@ interface network { ipv6, } + @since(version = 0.2.0) type ipv4-address = tuple; + @since(version = 0.2.0) type ipv6-address = tuple; + @since(version = 0.2.0) variant ip-address { ipv4(ipv4-address), ipv6(ipv6-address), } + @since(version = 0.2.0) record ipv4-socket-address { /// sin_port port: u16, @@ -126,6 +133,7 @@ interface network { address: ipv4-address, } + @since(version = 0.2.0) record ipv6-socket-address { /// sin6_port port: u16, @@ -137,9 +145,9 @@ interface network { scope-id: u32, } + @since(version = 0.2.0) variant ip-socket-address { ipv4(ipv4-socket-address), ipv6(ipv6-socket-address), } - } diff --git a/wit/deps/sockets/tcp-create-socket.wit b/wit/deps/sockets/tcp-create-socket.wit index c7ddf1f..eedbd30 100644 --- a/wit/deps/sockets/tcp-create-socket.wit +++ b/wit/deps/sockets/tcp-create-socket.wit @@ -1,6 +1,8 @@ - +@since(version = 0.2.0) interface tcp-create-socket { + @since(version = 0.2.0) use network.{network, error-code, ip-address-family}; + @since(version = 0.2.0) use tcp.{tcp-socket}; /// Create a new TCP socket. @@ -23,5 +25,6 @@ interface tcp-create-socket { /// - /// - /// - + @since(version = 0.2.0) create-tcp-socket: func(address-family: ip-address-family) -> result; } diff --git a/wit/deps/sockets/tcp.wit b/wit/deps/sockets/tcp.wit index 5902b9e..e4a6210 100644 --- a/wit/deps/sockets/tcp.wit +++ b/wit/deps/sockets/tcp.wit @@ -1,10 +1,15 @@ - +@since(version = 0.2.0) interface tcp { + @since(version = 0.2.0) use wasi:io/streams@0.2.0.{input-stream, output-stream}; + @since(version = 0.2.0) use wasi:io/poll@0.2.0.{pollable}; + @since(version = 0.2.0) use wasi:clocks/monotonic-clock@0.2.0.{duration}; + @since(version = 0.2.0) use network.{network, error-code, ip-socket-address, ip-address-family}; + @since(version = 0.2.0) enum shutdown-type { /// Similar to `SHUT_RD` in POSIX. receive, @@ -27,8 +32,8 @@ interface tcp { /// - `connect-in-progress` /// - `connected` /// - `closed` - /// See - /// for a more information. + /// See + /// for more information. /// /// Note: Except where explicitly mentioned, whenever this documentation uses /// the term "bound" without backticks it actually means: in the `bound` state *or higher*. @@ -37,6 +42,7 @@ interface tcp { /// In addition to the general error codes documented on the /// `network::error-code` type, TCP socket methods may always return /// `error(invalid-state)` when in the `closed` state. + @since(version = 0.2.0) resource tcp-socket { /// Bind the socket to a specific network on the provided IP address and port. /// @@ -76,13 +82,15 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) start-bind: func(network: borrow, local-address: ip-socket-address) -> result<_, error-code>; + @since(version = 0.2.0) finish-bind: func() -> result<_, error-code>; /// Connect to a remote endpoint. /// /// On success: - /// - the socket is transitioned into the `connection` state. + /// - the socket is transitioned into the `connected` state. /// - a pair of streams is returned that can be used to read & write to the connection /// /// After a failed connection attempt, the socket will be in the `closed` @@ -121,7 +129,9 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) start-connect: func(network: borrow, remote-address: ip-socket-address) -> result<_, error-code>; + @since(version = 0.2.0) finish-connect: func() -> result, error-code>; /// Start listening for new connections. @@ -149,7 +159,9 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) start-listen: func() -> result<_, error-code>; + @since(version = 0.2.0) finish-listen: func() -> result<_, error-code>; /// Accept a new client socket. @@ -178,6 +190,7 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) accept: func() -> result, error-code>; /// Get the bound local address. @@ -196,6 +209,7 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) local-address: func() -> result; /// Get the remote address. @@ -208,16 +222,19 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) remote-address: func() -> result; /// Whether the socket is in the `listening` state. /// /// Equivalent to the SO_ACCEPTCONN socket option. + @since(version = 0.2.0) is-listening: func() -> bool; /// Whether this is a IPv4 or IPv6 socket. /// /// Equivalent to the SO_DOMAIN socket option. + @since(version = 0.2.0) address-family: func() -> ip-address-family; /// Hints the desired listen queue size. Implementations are free to ignore this. @@ -229,6 +246,7 @@ interface tcp { /// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen. /// - `invalid-argument`: (set) The provided value was 0. /// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` state. + @since(version = 0.2.0) set-listen-backlog-size: func(value: u64) -> result<_, error-code>; /// Enables or disables keepalive. @@ -240,7 +258,9 @@ interface tcp { /// These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true. /// /// Equivalent to the SO_KEEPALIVE socket option. + @since(version = 0.2.0) keep-alive-enabled: func() -> result; + @since(version = 0.2.0) set-keep-alive-enabled: func(value: bool) -> result<_, error-code>; /// Amount of time the connection has to be idle before TCP starts sending keepalive packets. @@ -253,7 +273,9 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) keep-alive-idle-time: func() -> result; + @since(version = 0.2.0) set-keep-alive-idle-time: func(value: duration) -> result<_, error-code>; /// The time between keepalive packets. @@ -266,7 +288,9 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) keep-alive-interval: func() -> result; + @since(version = 0.2.0) set-keep-alive-interval: func(value: duration) -> result<_, error-code>; /// The maximum amount of keepalive packets TCP should send before aborting the connection. @@ -279,7 +303,9 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) keep-alive-count: func() -> result; + @since(version = 0.2.0) set-keep-alive-count: func(value: u32) -> result<_, error-code>; /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. @@ -288,7 +314,9 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + @since(version = 0.2.0) hop-limit: func() -> result; + @since(version = 0.2.0) set-hop-limit: func(value: u8) -> result<_, error-code>; /// The kernel buffer space reserved for sends/receives on this socket. @@ -301,9 +329,13 @@ interface tcp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) receive-buffer-size: func() -> result; + @since(version = 0.2.0) set-receive-buffer-size: func(value: u64) -> result<_, error-code>; + @since(version = 0.2.0) send-buffer-size: func() -> result; + @since(version = 0.2.0) set-send-buffer-size: func(value: u64) -> result<_, error-code>; /// Create a `pollable` which can be used to poll for, or block on, @@ -318,11 +350,12 @@ interface tcp { /// `subscribe` only has to be called once per socket and can then be /// (re)used for the remainder of the socket's lifetime. /// - /// See - /// for a more information. + /// See + /// for more information. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; /// Initiate a graceful shutdown. @@ -335,7 +368,7 @@ interface tcp { /// associated with this socket will be closed and a FIN packet will be sent. /// - `both`: Same effect as `receive` & `send` combined. /// - /// This function is idempotent. Shutting a down a direction more than once + /// This function is idempotent; shutting down a direction more than once /// has no effect and returns `ok`. /// /// The shutdown function does not close (drop) the socket. @@ -348,6 +381,7 @@ interface tcp { /// - /// - /// - + @since(version = 0.2.0) shutdown: func(shutdown-type: shutdown-type) -> result<_, error-code>; } } diff --git a/wit/deps/sockets/udp-create-socket.wit b/wit/deps/sockets/udp-create-socket.wit index 0482d1f..e8eeacb 100644 --- a/wit/deps/sockets/udp-create-socket.wit +++ b/wit/deps/sockets/udp-create-socket.wit @@ -1,6 +1,8 @@ - +@since(version = 0.2.0) interface udp-create-socket { + @since(version = 0.2.0) use network.{network, error-code, ip-address-family}; + @since(version = 0.2.0) use udp.{udp-socket}; /// Create a new UDP socket. @@ -23,5 +25,6 @@ interface udp-create-socket { /// - /// - /// - + @since(version = 0.2.0) create-udp-socket: func(address-family: ip-address-family) -> result; } diff --git a/wit/deps/sockets/udp.wit b/wit/deps/sockets/udp.wit index d987a0a..48e753c 100644 --- a/wit/deps/sockets/udp.wit +++ b/wit/deps/sockets/udp.wit @@ -1,9 +1,12 @@ - +@since(version = 0.2.0) interface udp { + @since(version = 0.2.0) use wasi:io/poll@0.2.0.{pollable}; + @since(version = 0.2.0) use network.{network, error-code, ip-socket-address, ip-address-family}; /// A received datagram. + @since(version = 0.2.0) record incoming-datagram { /// The payload. /// @@ -19,6 +22,7 @@ interface udp { } /// A datagram to be sent out. + @since(version = 0.2.0) record outgoing-datagram { /// The payload. data: list, @@ -33,9 +37,8 @@ interface udp { remote-address: option, } - - /// A UDP socket handle. + @since(version = 0.2.0) resource udp-socket { /// Bind the socket to a specific network on the provided IP address and port. /// @@ -63,7 +66,9 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) start-bind: func(network: borrow, local-address: ip-socket-address) -> result<_, error-code>; + @since(version = 0.2.0) finish-bind: func() -> result<_, error-code>; /// Set up inbound & outbound communication channels, optionally to a specific peer. @@ -106,6 +111,7 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) %stream: func(remote-address: option) -> result, error-code>; /// Get the current bound address. @@ -124,6 +130,7 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) local-address: func() -> result; /// Get the address the socket is currently streaming to. @@ -136,11 +143,13 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) remote-address: func() -> result; /// Whether this is a IPv4 or IPv6 socket. /// /// Equivalent to the SO_DOMAIN socket option. + @since(version = 0.2.0) address-family: func() -> ip-address-family; /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. @@ -149,7 +158,9 @@ interface udp { /// /// # Typical errors /// - `invalid-argument`: (set) The TTL value must be 1 or higher. + @since(version = 0.2.0) unicast-hop-limit: func() -> result; + @since(version = 0.2.0) set-unicast-hop-limit: func(value: u8) -> result<_, error-code>; /// The kernel buffer space reserved for sends/receives on this socket. @@ -162,18 +173,24 @@ interface udp { /// /// # Typical errors /// - `invalid-argument`: (set) The provided value was 0. + @since(version = 0.2.0) receive-buffer-size: func() -> result; + @since(version = 0.2.0) set-receive-buffer-size: func(value: u64) -> result<_, error-code>; + @since(version = 0.2.0) send-buffer-size: func() -> result; + @since(version = 0.2.0) set-send-buffer-size: func(value: u64) -> result<_, error-code>; /// Create a `pollable` which will resolve once the socket is ready for I/O. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; } + @since(version = 0.2.0) resource incoming-datagram-stream { /// Receive messages on the socket. /// @@ -198,15 +215,18 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) receive: func(max-results: u64) -> result, error-code>; /// Create a `pollable` which will resolve once the stream is ready to receive again. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; } + @since(version = 0.2.0) resource outgoing-datagram-stream { /// Check readiness for sending. This function never blocks. /// @@ -255,12 +275,14 @@ interface udp { /// - /// - /// - + @since(version = 0.2.0) send: func(datagrams: list) -> result; /// Create a `pollable` which will resolve once the stream is ready to send again. /// /// Note: this function is here for WASI Preview2 only. /// It's planned to be removed when `future` is natively supported in Preview3. + @since(version = 0.2.0) subscribe: func() -> pollable; } } diff --git a/wit/deps/sockets/world.wit b/wit/deps/sockets/world.wit index f8bb92a..a1f7d14 100644 --- a/wit/deps/sockets/world.wit +++ b/wit/deps/sockets/world.wit @@ -1,11 +1,19 @@ package wasi:sockets@0.2.0; +@since(version = 0.2.0) world imports { + @since(version = 0.2.0) import instance-network; + @since(version = 0.2.0) import network; + @since(version = 0.2.0) import udp; + @since(version = 0.2.0) import udp-create-socket; + @since(version = 0.2.0) import tcp; + @since(version = 0.2.0) import tcp-create-socket; + @since(version = 0.2.0) import ip-name-lookup; } diff --git a/wit/environment.wit b/wit/environment.wit index 7006523..2f449bd 100644 --- a/wit/environment.wit +++ b/wit/environment.wit @@ -1,3 +1,4 @@ +@since(version = 0.2.0) interface environment { /// Get the POSIX-style environment variables. /// @@ -7,12 +8,15 @@ interface environment { /// Morally, these are a value import, but until value imports are available /// in the component model, this import function should return the same /// values each time it is called. + @since(version = 0.2.0) get-environment: func() -> list>; /// Get the POSIX-style arguments to the program. + @since(version = 0.2.0) get-arguments: func() -> list; /// Return a path that programs should use as their initial current working /// directory, interpreting `.` as shorthand for this. + @since(version = 0.2.0) initial-cwd: func() -> option; } diff --git a/wit/exit.wit b/wit/exit.wit index d0c2b82..357e670 100644 --- a/wit/exit.wit +++ b/wit/exit.wit @@ -1,4 +1,6 @@ +@since(version = 0.2.0) interface exit { /// Exit the current instance and any linked instances. + @since(version = 0.2.0) exit: func(status: result); } diff --git a/wit/imports.wit b/wit/imports.wit index 083b84a..cd59ba1 100644 --- a/wit/imports.wit +++ b/wit/imports.wit @@ -1,20 +1,36 @@ package wasi:cli@0.2.0; +@since(version = 0.2.0) world imports { + @since(version = 0.2.0) include wasi:clocks/imports@0.2.0; + @since(version = 0.2.0) include wasi:filesystem/imports@0.2.0; + @since(version = 0.2.0) include wasi:sockets/imports@0.2.0; + @since(version = 0.2.0) include wasi:random/imports@0.2.0; + @since(version = 0.2.0) include wasi:io/imports@0.2.0; + @since(version = 0.2.0) import environment; + @since(version = 0.2.0) import exit; + @since(version = 0.2.0) import stdin; + @since(version = 0.2.0) import stdout; + @since(version = 0.2.0) import stderr; + @since(version = 0.2.0) import terminal-input; + @since(version = 0.2.0) import terminal-output; + @since(version = 0.2.0) import terminal-stdin; + @since(version = 0.2.0) import terminal-stdout; + @since(version = 0.2.0) import terminal-stderr; } diff --git a/wit/run.wit b/wit/run.wit index a70ee8c..655346e 100644 --- a/wit/run.wit +++ b/wit/run.wit @@ -1,4 +1,6 @@ +@since(version = 0.2.0) interface run { /// Run the program. + @since(version = 0.2.0) run: func() -> result; } diff --git a/wit/stdio.wit b/wit/stdio.wit index 31ef35b..e9502a9 100644 --- a/wit/stdio.wit +++ b/wit/stdio.wit @@ -1,17 +1,26 @@ +@since(version = 0.2.0) interface stdin { + @since(version = 0.2.0) use wasi:io/streams@0.2.0.{input-stream}; + @since(version = 0.2.0) get-stdin: func() -> input-stream; } +@since(version = 0.2.0) interface stdout { + @since(version = 0.2.0) use wasi:io/streams@0.2.0.{output-stream}; + @since(version = 0.2.0) get-stdout: func() -> output-stream; } +@since(version = 0.2.0) interface stderr { + @since(version = 0.2.0) use wasi:io/streams@0.2.0.{output-stream}; + @since(version = 0.2.0) get-stderr: func() -> output-stream; } diff --git a/wit/terminal.wit b/wit/terminal.wit index 38c724e..d305498 100644 --- a/wit/terminal.wit +++ b/wit/terminal.wit @@ -3,8 +3,10 @@ /// In the future, this may include functions for disabling echoing, /// disabling input buffering so that keyboard events are sent through /// immediately, querying supported features, and so on. +@since(version = 0.2.0) interface terminal-input { /// The input side of a terminal. + @since(version = 0.2.0) resource terminal-input; } @@ -13,37 +15,48 @@ interface terminal-input { /// In the future, this may include functions for querying the terminal /// size, being notified of terminal size changes, querying supported /// features, and so on. +@since(version = 0.2.0) interface terminal-output { /// The output side of a terminal. + @since(version = 0.2.0) resource terminal-output; } /// An interface providing an optional `terminal-input` for stdin as a /// link-time authority. +@since(version = 0.2.0) interface terminal-stdin { + @since(version = 0.2.0) use terminal-input.{terminal-input}; /// If stdin is connected to a terminal, return a `terminal-input` handle /// allowing further interaction with it. + @since(version = 0.2.0) get-terminal-stdin: func() -> option; } /// An interface providing an optional `terminal-output` for stdout as a /// link-time authority. +@since(version = 0.2.0) interface terminal-stdout { + @since(version = 0.2.0) use terminal-output.{terminal-output}; /// If stdout is connected to a terminal, return a `terminal-output` handle /// allowing further interaction with it. + @since(version = 0.2.0) get-terminal-stdout: func() -> option; } /// An interface providing an optional `terminal-output` for stderr as a /// link-time authority. +@since(version = 0.2.0) interface terminal-stderr { + @since(version = 0.2.0) use terminal-output.{terminal-output}; /// If stderr is connected to a terminal, return a `terminal-output` handle /// allowing further interaction with it. + @since(version = 0.2.0) get-terminal-stderr: func() -> option; }