From aacbc2cef76d270c6e6b7aa31317e413e8f9a5f6 Mon Sep 17 00:00:00 2001
From: Yosh Get the POSIX-style environment variables. Each environment variable is provided as a pair of string variable names
and string value.
-
-
wasi:cli/environment@0.2.0
wasi:cli/exit@0.2.0
wasi:io/error@0.2.0
wasi:io/poll@0.2.0
wasi:io/streams@0.2.0
wasi:cli/stdin@0.2.0
wasi:cli/stdout@0.2.0
wasi:cli/stderr@0.2.0
wasi:cli/terminal-input@0.2.0
wasi:cli/terminal-output@0.2.0
wasi:cli/terminal-stdin@0.2.0
wasi:cli/terminal-stdout@0.2.0
wasi:cli/terminal-stderr@0.2.0
wasi:clocks/monotonic-clock@0.2.0
wasi:clocks/wall-clock@0.2.0
wasi:filesystem/types@0.2.0
wasi:filesystem/preopens@0.2.0
wasi:sockets/network@0.2.0
wasi:sockets/instance-network@0.2.0
wasi:sockets/udp@0.2.0
wasi:sockets/udp-create-socket@0.2.0
wasi:sockets/tcp@0.2.0
wasi:sockets/tcp-create-socket@0.2.0
wasi:sockets/ip-name-lookup@0.2.0
wasi:random/random@0.2.0
wasi:random/insecure@0.2.0
wasi:random/insecure-seed@0.2.0
wasi:cli/environment@0.2.0
wasi:cli/exit@0.2.0
wasi:io/error@0.2.0
wasi:io/poll@0.2.0
wasi:io/streams@0.2.0
wasi:cli/stdin@0.2.0
wasi:cli/stdout@0.2.0
wasi:cli/stderr@0.2.0
wasi:cli/terminal-input@0.2.0
wasi:cli/terminal-output@0.2.0
wasi:cli/terminal-stdin@0.2.0
wasi:cli/terminal-stdout@0.2.0
wasi:cli/terminal-stderr@0.2.0
wasi:clocks/monotonic-clock@0.2.0
wasi:clocks/wall-clock@0.2.0
wasi:filesystem/types@0.2.0
wasi:filesystem/preopens@0.2.0
wasi:sockets/network@0.2.0
wasi:sockets/instance-network@0.2.0
wasi:sockets/udp@0.2.0
wasi:sockets/udp-create-socket@0.2.0
wasi:sockets/tcp@0.2.0
wasi:sockets/tcp-create-socket@0.2.0
wasi:sockets/ip-name-lookup@0.2.0
wasi:random/random@0.2.0
wasi:random/insecure@0.2.0
wasi:random/insecure-seed@0.2.0
-
wasi:cli/run@0.2.0
wasi:cli/run@0.2.0
Import interface wasi:cli/environment@0.2.0
+Import interface wasi:cli/environment@0.2.0
Functions
-
+get-environment: func
get-environment: func
get-arguments: func
get-arguments: func
Get the POSIX-style arguments to the program.
initial-cwd: func
initial-cwd: func
Return a path that programs should use as their initial current working
directory, interpreting .
as shorthand for this.
exit: func
exit: func
Exit the current instance and any linked instances.
status
: resultstatus
: resultresource 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, 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<error>
and returns
-option<wasi:filesystem/types/error-code>
.
wasi:filesystem/types/filesystem-error-code
, which takes a borrow<error>
+parameter and returns an option<wasi:filesystem/types/error-code>
.
error
into a more
concrete type is open.[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.
A poll API intended to let users wait for I/O events on multiple handles at once.
resource pollable
resource pollable
pollable
represents a single I/O event which may be ready, or not.[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.
[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.
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:
+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.
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.
type error
type error
-#### `type pollable` +#### `type pollable` [`pollable`](#pollable)
-#### `variant stream-error` +#### `variant stream-error`
An error for input-stream and output-stream operations.
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.
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-stream
s 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-stream
s 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
.[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.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>u8
>, stream-error
>[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
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u8
>, stream-error
>u8
>, stream-error
>[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.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>u64
, stream-error
>[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
.
self
: borrow<input-stream
>len
: u64
self
: borrow<input-stream
>len
: u64
u64
, stream-error
>u64
, stream-error
>[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-stream
pollable
s created with this function are dropped.
self
: borrow<input-stream
>self
: borrow<input-stream
>[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.
self
: borrow<output-stream
>self
: borrow<output-stream
>u64
, stream-error
>u64
, stream-error
>[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.
self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>stream-error
>[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
self
: borrow<output-stream
>contents
: list<u8
>self
: borrow<output-stream
>contents
: list<u8
>stream-error
>stream-error
>[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.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>stream-error
>[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.
self
: borrow<output-stream
>self
: borrow<output-stream
>stream-error
>stream-error
>[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-stream
s created with this function are dropped.pollable
self
: borrow<output-stream
>self
: borrow<output-stream
>[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.
self
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>stream-error
>[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 handlingself
: borrow<output-stream
>len
: u64
self
: borrow<output-stream
>len
: u64
stream-error
>stream-error
>[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:
len
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>u64
, stream-error
>[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
.
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
self
: borrow<output-stream
>src
: borrow<input-stream
>len
: u64
u64
, stream-error
>u64
, stream-error
>type input-stream
type input-stream
----
get-stdin: func
get-stdin: func
input-stream
>type output-stream
type output-stream
----
get-stdout: func
get-stdout: func
output-stream
>type output-stream
type output-stream
----
get-stderr: func
get-stderr: func
output-stream
>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.
resource terminal-input
resource terminal-input
The input side of a terminal.
-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.
resource terminal-output
resource terminal-output
The output side of a terminal.
-An interface providing an optional terminal-input
for stdin as a
link-time authority.
type terminal-input
type terminal-input
----
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.
terminal-input
>>An interface providing an optional terminal-output
for stdout as a
link-time authority.
type terminal-output
type terminal-output
----
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.
terminal-output
>>An interface providing an optional terminal-output
for stderr as a
link-time authority.
type terminal-output
type terminal-output
----
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.
terminal-output
>>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.
type pollable
type 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.
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.
subscribe-instant: func
subscribe-instant: func
Create a pollable
which will resolve once the specified instant
-occured.
pollable
>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.
pollable
>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.
record datetime
record datetime
A time and date in seconds plus nanoseconds.
seconds
: u64
nanoseconds
: u32
seconds
: u64
nanoseconds
: u32
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. -resolution: func
resolution: func
Query the resolution of the clock.
The nanoseconds field of the output is always less than 1000000000.
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.type input-stream
type 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.
The type of the descriptor or file is unknown or is different from any of the other types specified.
The descriptor refers to a block device inode.
The descriptor refers to a character device inode.
The descriptor refers to a directory inode.
The descriptor refers to a named pipe.
The file refers to a symbolic link inode.
The descriptor refers to a regular file inode.
The descriptor refers to a socket.
flags descriptor-flags
flags descriptor-flags
Descriptor flags.
Note: This was called fdflags
in earlier versions of WASI.
read
:
Read mode: Data can be read.
Write mode: Data can be written to.
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. @@ -790,7 +789,7 @@ WASI. At this time, it should be interpreted as a request, and not a requirement.
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. @@ -799,7 +798,7 @@ WASI. At this time, it should be interpreted as a request, and not a requirement.
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 @@ -807,7 +806,7 @@ WASI. At this time, it should be interpreted as a request, and not a requirement.
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 @@ -817,107 +816,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.
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
.
Create file if it does not exist, similar to `O_CREAT` in POSIX.
Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
Fail if file already exists, similar to `O_EXCL` in POSIX.
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.
type
: descriptor-type
File type.
Number of hard links to the file.
size
: filesize
For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
data-access-timestamp
: option<datetime
>
data-access-timestamp
: option<datetime
>
Last data access timestamp.
If the option
is none, the platform doesn't maintain an access
timestamp for this file.
data-modification-timestamp
: option<datetime
>
data-modification-timestamp
: option<datetime
>
Last data modification timestamp.
If the option
is none, the platform doesn't maintain a
modification timestamp for this file.
status-change-timestamp
: option<datetime
>
status-change-timestamp
: option<datetime
>
Last file status-change timestamp.
If the option
is none, the platform doesn't maintain a
status-change timestamp for this file.
variant new-timestamp
variant new-timestamp
When setting a timestamp, this gives the value to set it to.
Leave the timestamp set to its previous value.
Set the timestamp to the current time of the system clock associated with the filesystem.
timestamp
: datetime
Set the timestamp to the given value.
record directory-entry
record directory-entry
A directory entry.
type
: descriptor-type
The type of the file referred to by this directory entry.
name
: string
The name of the object.
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.
Permission denied, similar to `EACCES` in POSIX.
Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
Connection already in progress, similar to `EALREADY` in POSIX.
Bad descriptor, similar to `EBADF` in POSIX.
Device or resource busy, similar to `EBUSY` in POSIX.
Resource deadlock would occur, similar to `EDEADLK` in POSIX.
Storage quota exceeded, similar to `EDQUOT` in POSIX.
File exists, similar to `EEXIST` in POSIX.
File too large, similar to `EFBIG` in POSIX.
Illegal byte sequence, similar to `EILSEQ` in POSIX.
Operation in progress, similar to `EINPROGRESS` in POSIX.
Interrupted function, similar to `EINTR` in POSIX.
Invalid argument, similar to `EINVAL` in POSIX.
I/O error, similar to `EIO` in POSIX.
Is a directory, similar to `EISDIR` in POSIX.
Too many levels of symbolic links, similar to `ELOOP` in POSIX.
Too many links, similar to `EMLINK` in POSIX.
Message too large, similar to `EMSGSIZE` in POSIX.
Filename too long, similar to `ENAMETOOLONG` in POSIX.
No such device, similar to `ENODEV` in POSIX.
No such file or directory, similar to `ENOENT` in POSIX.
No locks available, similar to `ENOLCK` in POSIX.
Not enough space, similar to `ENOMEM` in POSIX.
No space left on device, similar to `ENOSPC` in POSIX.
Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
Directory not empty, similar to `ENOTEMPTY` in POSIX.
State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
No such device or address, similar to `ENXIO` in POSIX.
Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
Operation not permitted, similar to `EPERM` in POSIX.
Broken pipe, similar to `EPIPE` in POSIX.
Read-only file system, similar to `EROFS` in POSIX.
Invalid seek, similar to `ESPIPE` in POSIX.
Text file busy, similar to `ETXTBSY` in POSIX.
Cross-device link, similar to `EXDEV` in POSIX.
enum advice
enum advice
File or memory access pattern advisory information.
The application has no advice to give on its behavior with respect to the specified data.
The application expects to access the specified data sequentially from lower offsets to higher offsets.
The application expects to access the specified data in a random order.
The application expects to access the specified data in the near future.
The application expects that it will not access the specified data in the near future.
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.
lower
: u64
64 bits of a 128-bit hash value.
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
[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.
self
: borrow<descriptor
>offset
: filesize
self
: borrow<descriptor
>offset
: filesize
input-stream
>, error-code
>input-stream
>, error-code
>[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.
self
: borrow<descriptor
>offset
: filesize
self
: borrow<descriptor
>offset
: filesize
output-stream
>, error-code
>output-stream
>, error-code
>[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.
self
: borrow<descriptor
>self
: borrow<descriptor
>output-stream
>, error-code
>output-stream
>, error-code
>[method]descriptor.advise: func
[method]descriptor.advise: func
Provide file advisory information on a descriptor.
This is similar to posix_fadvise
in POSIX.
self
: borrow<descriptor
>offset
: filesize
length
: filesize
advice
: advice
self
: borrow<descriptor
>offset
: filesize
length
: filesize
advice
: advice
error-code
>error-code
>[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.
self
: borrow<descriptor
>self
: borrow<descriptor
>error-code
>error-code
>[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.
self
: borrow<descriptor
>self
: borrow<descriptor
>descriptor-flags
, error-code
>descriptor-flags
, error-code
>[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.
fstat
in POSIX.
from fdstat_get
in earlier versions of WASI.
self
: borrow<descriptor
>self
: borrow<descriptor
>descriptor-type
, error-code
>descriptor-type
, error-code
>[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.
self
: borrow<descriptor
>size
: filesize
self
: borrow<descriptor
>size
: filesize
error-code
>error-code
>[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.
self
: borrow<descriptor
>data-access-timestamp
: new-timestamp
data-modification-timestamp
: new-timestamp
self
: borrow<descriptor
>data-access-timestamp
: new-timestamp
data-modification-timestamp
: new-timestamp
error-code
>error-code
>[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.
self
: borrow<descriptor
>length
: filesize
offset
: filesize
self
: borrow<descriptor
>length
: filesize
offset
: filesize
u8
>, bool
), error-code
>u8
>, bool
), error-code
>[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.
self
: borrow<descriptor
>buffer
: list<u8
>offset
: filesize
self
: borrow<descriptor
>buffer
: list<u8
>offset
: filesize
filesize
, error-code
>filesize
, error-code
>[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.
self
: borrow<descriptor
>self
: borrow<descriptor
>directory-entry-stream
>, error-code
>directory-entry-stream
>, error-code
>[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.
self
: borrow<descriptor
>self
: borrow<descriptor
>error-code
>error-code
>[method]descriptor.create-directory-at: func
[method]descriptor.create-directory-at: func
Create a directory.
Note: This is similar to mkdirat
in POSIX.
self
: borrow<descriptor
>path
: string
self
: borrow<descriptor
>path
: string
error-code
>error-code
>[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.
self
: borrow<descriptor
>self
: borrow<descriptor
>descriptor-stat
, error-code
>descriptor-stat
, error-code
>[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.
self
: borrow<descriptor
>path-flags
: path-flags
path
: string
self
: borrow<descriptor
>path-flags
: path-flags
path
: string
descriptor-stat
, error-code
>descriptor-stat
, error-code
>[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.
self
: borrow<descriptor
>path-flags
: path-flags
path
: string
data-access-timestamp
: new-timestamp
data-modification-timestamp
: new-timestamp
self
: borrow<descriptor
>path-flags
: path-flags
path
: string
data-access-timestamp
: new-timestamp
data-modification-timestamp
: new-timestamp
error-code
>error-code
>[method]descriptor.link-at: func
[method]descriptor.link-at: func
Create a hard link.
Note: This is similar to linkat
in POSIX.
self
: borrow<descriptor
>old-path-flags
: path-flags
old-path
: string
new-descriptor
: borrow<descriptor
>new-path
: string
self
: borrow<descriptor
>old-path-flags
: path-flags
old-path
: string
new-descriptor
: borrow<descriptor
>new-path
: string
error-code
>error-code
>[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.
self
: borrow<descriptor
>path-flags
: path-flags
path
: string
open-flags
: open-flags
flags
: descriptor-flags
self
: borrow<descriptor
>path-flags
: path-flags
path
: string
open-flags
: open-flags
flags
: descriptor-flags
descriptor
>, error-code
>descriptor
>, error-code
>[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.
self
: borrow<descriptor
>path
: string
self
: borrow<descriptor
>path
: string
string
, error-code
>string
, error-code
>[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.
self
: borrow<descriptor
>path
: string
self
: borrow<descriptor
>path
: string
error-code
>error-code
>[method]descriptor.rename-at: func
[method]descriptor.rename-at: func
Rename a filesystem object.
Note: This is similar to renameat
in POSIX.
self
: borrow<descriptor
>old-path
: string
new-descriptor
: borrow<descriptor
>new-path
: string
self
: borrow<descriptor
>old-path
: string
new-descriptor
: borrow<descriptor
>new-path
: string
error-code
>error-code
>[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.
self
: borrow<descriptor
>old-path
: string
new-path
: string
self
: borrow<descriptor
>old-path
: string
new-path
: string
error-code
>error-code
>[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.
self
: borrow<descriptor
>path
: string
self
: borrow<descriptor
>path
: string
error-code
>error-code
>[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.
self
: borrow<descriptor
>other
: borrow<descriptor
>self
: borrow<descriptor
>other
: borrow<descriptor
>[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.
self
: borrow<descriptor
>self
: borrow<descriptor
>metadata-hash-value
, error-code
>metadata-hash-value
, error-code
>[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
.
self
: borrow<descriptor
>path-flags
: path-flags
path
: string
self
: borrow<descriptor
>path-flags
: path-flags
path
: string
metadata-hash-value
, error-code
>metadata-hash-value
, error-code
>[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
.
self
: borrow<directory-entry-stream
>self
: borrow<directory-entry-stream
>directory-entry
>, error-code
>directory-entry
>, error-code
>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.
error-code
>type descriptor
type descriptor
----
get-directories: func
get-directories: func
Return the set of preopened directories, and their path.
descriptor
>, string
)>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:
Unknown error
Access denied.
POSIX equivalent: EACCES, EPERM
The operation is not supported.
POSIX equivalent: EOPNOTSUPP
One of the arguments is invalid.
POSIX equivalent: EINVAL
Not enough memory to complete the operation.
POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
The operation timed out before it could finish completely.
This operation is incompatible with another asynchronous operation that is already in progress.
POSIX equivalent: EALREADY
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 future
s are natively supported.
The operation has been aborted because it could not be completed immediately.
Note: this is scheduled to be removed when future
s are natively supported.
The operation is not valid in the socket's current state.
A new socket resource could not be created because of a system limit.
A bind operation failed because the provided address is not an address that the `network` can bind to.
A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.
The remote address is not reachable
The TCP connection was forcefully rejected
The TCP connection was reset.
A TCP connection was aborted.
The size of a datagram sent to a UDP socket exceeded the maximum supported size.
Name does not exist or has no suitable associated IP addresses.
A temporary failure in name resolution occurred.
A permanent failure in name resolution occurred.
enum ip-address-family
enum ip-address-family
tuple ipv4-address
tuple ipv4-address
tuple ipv6-address
tuple ipv6-address
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
ipv4
: ipv4-address
ipv6
: ipv6-address
ipv4
: ipv4-address
ipv6
: ipv6-address
record ipv4-socket-address
record ipv4-socket-address
port
: u16
sin_port
address
: ipv4-address
sin_addr
record ipv6-socket-address
record ipv6-socket-address
port
: u16
sin6_port
flow-info
: u32
sin6_flowinfo
address
: ipv6-address
sin6_addr
scope-id
: u32
sin6_scope_id
variant ip-socket-address
variant ip-socket-address
ipv4
: ipv4-socket-address
ipv6
: ipv6-socket-address
ipv4
: ipv4-socket-address
ipv6
: ipv6-socket-address
This interface provides a value-export of the default network handle..
type network
type network
----
instance-network: func
instance-network: func
Get a handle to the default network.
network
>type pollable
type 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.
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.
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:
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
[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.
@@ -1883,24 +1882,24 @@ don't want to make use of this ability can simply call the native
self
: borrow<udp-socket
>network
: borrow<network
>local-address
: ip-socket-address
self
: borrow<udp-socket
>network
: borrow<network
>local-address
: ip-socket-address
error-code
>error-code
>[method]udp-socket.finish-bind: func
[method]udp-socket.finish-bind: func
self
: borrow<udp-socket
>self
: borrow<udp-socket
>error-code
>error-code
>[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) {
self
: borrow<udp-socket
>remote-address
: option<ip-socket-address
>self
: borrow<udp-socket
>remote-address
: option<ip-socket-address
>incoming-datagram-stream
>, own<outgoing-datagram-stream
>), error-code
>incoming-datagram-stream
>, own<outgoing-datagram-stream
>), error-code
>[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 byaddress
is unspecified.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[method]udp-socket.remote-address: func
[method]udp-socket.remote-address: func
Get the address the socket is currently streaming to.
Typical errors
@@ -1990,24 +1989,24 @@ stored in the object pointed to by
address
is unspecified.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[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
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>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 byaddress
is unspecified.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u8
,error-code
>- result<
u8
,error-code
>+
[method]udp-socket.set-unicast-hop-limit: func
[method]udp-socket.set-unicast-hop-limit: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u8
- +
self
: borrow<udp-socket
>value
:u8
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]udp-socket.set-receive-buffer-size: func
[method]udp-socket.set-receive-buffer-size: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u64
- +
self
: borrow<udp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]udp-socket.send-buffer-size: func
[method]udp-socket.send-buffer-size: func
Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]udp-socket.set-send-buffer-size: func
[method]udp-socket.set-send-buffer-size: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u64
- +
self
: borrow<udp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>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
@@ -2119,26 +2118,26 @@ This function never returnsmax-results
datagrams on the socket without blocking. The returned list may contain fewer elements than requested, but never more.error(would-block)
.Params
-
- -
self
: borrow<incoming-datagram-stream
>- +
max-results
:u64
- +
self
: borrow<incoming-datagram-stream
>max-results
:u64
Return values
-
-- result<list<
+incoming-datagram
>,error-code
>- result<list<
incoming-datagram
>,error-code
>+
[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
-
- +
self
: borrow<incoming-datagram-stream
>self
: borrow<incoming-datagram-stream
>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. Callingsend
with more datagrams than this function has @@ -2149,13 +2148,13 @@ error.Never returns
would-block
.Params
-
- +
self
: borrow<outgoing-datagram-stream
>self
: borrow<outgoing-datagram-stream
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[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 @@ eithercheck-send
was not called ordatagrams
containsParams
-
- -
self
: borrow<outgoing-datagram-stream
>- +
datagrams
: list<outgoing-datagram
>- +
self
: borrow<outgoing-datagram-stream
>datagrams
: list<outgoing-datagram
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[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
-
- +
self
: borrow<outgoing-datagram-stream
>self
: borrow<outgoing-datagram-stream
>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
-#### `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
@@ -2248,56 +2247,56 @@ the socket is effectively an in-memory configuration object, unable to communicasocket(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.Params
-
- +
address-family
:ip-address-family
address-family
:ip-address-family
Return values
-
- result<own<
udp-socket
>,error-code
>Import interface wasi:sockets/tcp@0.2.0
+Import interface wasi:sockets/tcp@0.2.0
Types
-+
type input-stream
type 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
-
- - +
Similar to `SHUT_RD` in POSIX.
- - +
Similar to `SHUT_WR` in POSIX.
- - +
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:
@@ -2309,8 +2308,8 @@ the socket is effectively an in-memory configuration object, unable to communica
connect-in-progress
connected
- +See https://github.com/WebAssembly/wasi-sockets/blob/main/TcpSocketOperationalSemantics.md +for more information.
closed
-See https://github.com/WebAssembly/wasi-sockets/TcpSocketOperationalSemantics.md -for a 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. @@ -2319,7 +2318,7 @@ the term "bound" without backticks it actually means: in thebou
network::error-code
type, TCP socket methods may always returnerror(invalid-state)
when in theclosed
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 nativeParams
-
- -
self
: borrow<tcp-socket
>- -
network
: borrow<network
>- +
local-address
:ip-socket-address
- +
self
: borrow<tcp-socket
>- +
network
: borrow<network
>local-address
:ip-socket-address
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-bind: func
[method]tcp-socket.finish-bind: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 @@ theSO_ERROR
socket option, in case the poll signaled readiness.Params
-
- -
self
: borrow<tcp-socket
>- -
network
: borrow<network
>- +
remote-address
:ip-socket-address
- +
self
: borrow<tcp-socket
>- +
network
: borrow<network
>remote-address
:ip-socket-address
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-connect: func
[method]tcp-socket.finish-connect: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<(own<
+input-stream
>, own<output-stream
>),error-code
>- result<(own<
input-stream
>, own<output-stream
>),error-code
>+
[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 nativeParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-listen: func
[method]tcp-socket.finish-listen: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<(own<
+tcp-socket
>, own<input-stream
>, own<output-stream
>),error-code
>- result<(own<
tcp-socket
>, own<input-stream
>, own<output-stream
>),error-code
>+
[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 byaddress
is unspecified.Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-+
[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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>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
@@ -2598,14 +2597,14 @@ Any other value will never cause an error, but it might be silently clamped and/invalid-argument
error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded.Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 falsEquivalent to the SO_KEEPALIVE socket option.
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+bool
,error-code
>- result<
bool
,error-code
>+
[method]tcp-socket.set-keep-alive-enabled: func
[method]tcp-socket.set-keep-alive-enabled: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:bool
- +
self
: borrow<tcp-socket
>value
:bool
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+duration
,error-code
>- result<
duration
,error-code
>+
[method]tcp-socket.set-keep-alive-idle-time: func
[method]tcp-socket.set-keep-alive-idle-time: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:duration
- +
self
: borrow<tcp-socket
>value
:duration
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+duration
,error-code
>- result<
duration
,error-code
>+
[method]tcp-socket.set-keep-alive-interval: func
[method]tcp-socket.set-keep-alive-interval: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:duration
- +
self
: borrow<tcp-socket
>value
:duration
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u32
,error-code
>- result<
u32
,error-code
>+
[method]tcp-socket.set-keep-alive-count: func
[method]tcp-socket.set-keep-alive-count: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u32
- +
self
: borrow<tcp-socket
>value
:u32
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u8
,error-code
>- result<
u8
,error-code
>+
[method]tcp-socket.set-hop-limit: func
[method]tcp-socket.set-hop-limit: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u8
- +
self
: borrow<tcp-socket
>value
:u8
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]tcp-socket.set-receive-buffer-size: func
[method]tcp-socket.set-receive-buffer-size: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.send-buffer-size: func
[method]tcp-socket.send-buffer-size: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]tcp-socket.set-send-buffer-size: func
[method]tcp-socket.set-send-buffer-size: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
in progress at the time of callingfinish-bind
,finish-listen
,finish-connect
oraccept
@@ -2799,19 +2798,19 @@ their success or failure, after which the method can be retried.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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-+
[method]tcp-socket.shutdown: func
[method]tcp-socket.shutdown: func
Initiate a graceful shutdown.
-
- associated with this socket will be closed and a FIN packet will be sent.
receive
: The socket is not expecting to receive any data from @@ -2822,7 +2821,7 @@ this method will be discarded.both
: Same effect asreceive
&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 returnsok
.Params
-
- -
self
: borrow<tcp-socket
>- +
shutdown-type
:shutdown-type
- +
self
: borrow<tcp-socket
>shutdown-type
:shutdown-type
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>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
-#### `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
@@ -2884,31 +2883,31 @@ is called, the socket is effectively an in-memory configuration object, unable tsocket(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.Params
-
- +
address-family
:ip-address-family
address-family
:ip-address-family
Return values
-
- result<own<
tcp-socket
>,error-code
>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
-#### `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
-
- result<own<
resolve-address-stream
>,error-code
>+
[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
-
- +
self
: borrow<resolve-address-stream
>self
: borrow<resolve-address-stream
>Return values
-
-- result<option<
+ip-address
>,error-code
>- result<option<
ip-address
>,error-code
>+
[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
-
- +
self
: borrow<resolve-address-stream
>self
: borrow<resolve-address-stream
>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
-+
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
@@ -3003,13 +3002,13 @@ represented as aget-random-bytes
, represented as au64
.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
-+
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
@@ -3032,13 +3031,13 @@ a long period. -get-insecure-random-bytes
, represented as au64
.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.
-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
diff --git a/imports.md b/imports.md index 02f8f93..93e32c3 100644 --- a/imports.md +++ b/imports.md @@ -2,40 +2,40 @@
+ + +-
- Imports:
--
-- interface
-wasi:cli/environment@0.2.0
- interface
-wasi:cli/exit@0.2.0
- interface
-wasi:io/error@0.2.0
- interface
-wasi:io/poll@0.2.0
- interface
-wasi:io/streams@0.2.0
- interface
-wasi:cli/stdin@0.2.0
- interface
-wasi:cli/stdout@0.2.0
- interface
-wasi:cli/stderr@0.2.0
- interface
-wasi:cli/terminal-input@0.2.0
- interface
-wasi:cli/terminal-output@0.2.0
- interface
-wasi:cli/terminal-stdin@0.2.0
- interface
-wasi:cli/terminal-stdout@0.2.0
- interface
-wasi:cli/terminal-stderr@0.2.0
- interface
-wasi:clocks/monotonic-clock@0.2.0
- interface
-wasi:clocks/wall-clock@0.2.0
- interface
-wasi:filesystem/types@0.2.0
- interface
-wasi:filesystem/preopens@0.2.0
- interface
-wasi:sockets/network@0.2.0
- interface
-wasi:sockets/instance-network@0.2.0
- interface
-wasi:sockets/udp@0.2.0
- interface
-wasi:sockets/udp-create-socket@0.2.0
- interface
-wasi:sockets/tcp@0.2.0
- interface
-wasi:sockets/tcp-create-socket@0.2.0
- interface
-wasi:sockets/ip-name-lookup@0.2.0
- interface
-wasi:random/random@0.2.0
- interface
-wasi:random/insecure@0.2.0
- interface
-wasi:random/insecure-seed@0.2.0
Import interface wasi:cli/environment@0.2.0
+- interface
+wasi:cli/environment@0.2.0
- interface
+wasi:cli/exit@0.2.0
- interface
+wasi:io/error@0.2.0
- interface
+wasi:io/poll@0.2.0
- interface
+wasi:io/streams@0.2.0
- interface
+wasi:cli/stdin@0.2.0
- interface
+wasi:cli/stdout@0.2.0
- interface
+wasi:cli/stderr@0.2.0
- interface
+wasi:cli/terminal-input@0.2.0
- interface
+wasi:cli/terminal-output@0.2.0
- interface
+wasi:cli/terminal-stdin@0.2.0
- interface
+wasi:cli/terminal-stdout@0.2.0
- interface
+wasi:cli/terminal-stderr@0.2.0
- interface
+wasi:clocks/monotonic-clock@0.2.0
- interface
+wasi:clocks/wall-clock@0.2.0
- interface
+wasi:filesystem/types@0.2.0
- interface
+wasi:filesystem/preopens@0.2.0
- interface
+wasi:sockets/network@0.2.0
- interface
+wasi:sockets/instance-network@0.2.0
- interface
+wasi:sockets/udp@0.2.0
- interface
+wasi:sockets/udp-create-socket@0.2.0
- interface
+wasi:sockets/tcp@0.2.0
- interface
+wasi:sockets/tcp-create-socket@0.2.0
- interface
+wasi:sockets/ip-name-lookup@0.2.0
- interface
+wasi:random/random@0.2.0
- interface
+wasi:random/insecure@0.2.0
- interface
+wasi:random/insecure-seed@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.
@@ -46,49 +46,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
-
-- +
status
: resultstatus
: resultImport 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 thewasi: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,
+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 +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<error>
and returns -option<wasi:filesystem/types/error-code>
.wasi:filesystem/types/filesystem-error-code
, which takes aborrow<error>
+parameter and returns anoption<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
-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, andfalse
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:
++
- 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
+being ready for I/O.result
; polling in itself does not do any I/O so it doesn't fail. If any of the I/O sources identified by the pollables has an error, it is indicated by marking the source as -being reaedy for I/O.Params
Return values
-Import interface wasi:io/streams@0.2.0
+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
-#### `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.- - +
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-stream
s 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 thesubscribe
function to obtain apollable
which can be polled for usingwasi:io/poll
.+
resource output-stream
resource output-stream
An output bytestream.
output-stream
s 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, thesubscribe
function to obtain apollable
which can be polled for usingwasi: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 aread
is known to the @@ -223,51 +224,51 @@ as a return value by the callee. The callee may return a list of bytes less thanlen
in size while more bytes are available for reading.Params
-
- -
self
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<input-stream
>len
:u64
Return values
-
-- result<list<
+u8
>,stream-error
>- result<list<
u8
>,stream-error
>+
[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
-
- -
self
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<input-stream
>len
:u64
Return values
-
-- result<list<
+u8
>,stream-error
>- result<list<
u8
>,stream-error
>+
[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
-
- -
self
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<input-stream
>len
:u64
Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>+
[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
-
- -
self
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<input-stream
>len
:u64
Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>+
[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 theinput-stream
pollable
s created with this function are dropped.Params
-
- +
self
: borrow<input-stream
>self
: borrow<input-stream
>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. Callingwrite
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
-
- +
self
: borrow<output-stream
>self
: borrow<output-stream
>Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>+
[method]output-stream.write: func
[method]output-stream.write: func
Perform a write. This function never blocks.
When the destination of a
the last call to check-write provided a permit.write
is binary data, the bytes fromcontents
are written verbatim. When the destination of awrite
is @@ -311,14 +312,14 @@ length of less than or equal to n. Otherwise, this function will trap.Params
-
- -
self
: borrow<output-stream
>- +
contents
: list<u8
>- +
self
: borrow<output-stream
>contents
: list<u8
>Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[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 handlingParams
-
- -
self
: borrow<output-stream
>- +
contents
: list<u8
>- +
self
: borrow<output-stream
>contents
: list<u8
>Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[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
-
- +
self
: borrow<output-stream
>self
: borrow<output-stream
>Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[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
-
- +
self
: borrow<output-stream
>self
: borrow<output-stream
>Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[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 returnok(n)
with n>0, or an @@ -388,13 +389,13 @@ Implementations may trap if theoutput-stream
s created with this function are dropped.pollable
Params
-
- +
self
: borrow<output-stream
>self
: borrow<output-stream
>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
-
- -
self
: borrow<output-stream
>- +
len
:u64
- +
self
: borrow<output-stream
>len
:u64
Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[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 handlingParams
-
- -
self
: borrow<output-stream
>- +
len
:u64
- +
self
: borrow<output-stream
>len
:u64
Return values
-
-- result<_,
+stream-error
>- result<_,
stream-error
>+
[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
-
- -
self
: borrow<output-stream
>- -
src
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<output-stream
>- +
src
: borrow<input-stream
>len
:u64
Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>+
[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 theoutput-stream
is ready for writing, and theinput-stream
is ready for reading, before performing thesplice
.Params
-
- -
self
: borrow<output-stream
>- -
src
: borrow<input-stream
>- +
len
:u64
- +
self
: borrow<output-stream
>- +
src
: borrow<input-stream
>len
:u64
Return values
-
-- result<
+u64
,stream-error
>- result<
u64
,stream-error
>Import interface wasi:cli/stdin@0.2.0
+Import interface wasi:cli/stdin@0.2.0
Types
-+
type input-stream
type input-stream
----
Functions
-+
get-stdin: func
get-stdin: func
Return values
-
- own<
input-stream
>Import interface wasi:cli/stdout@0.2.0
+Import interface wasi:cli/stdout@0.2.0
Types
-+
type output-stream
type output-stream
----
Functions
-+
get-stdout: func
get-stdout: func
Return values
-
- own<
output-stream
>Import interface wasi:cli/stderr@0.2.0
+Import interface wasi:cli/stderr@0.2.0
Types
-+
type output-stream
type output-stream
----
Functions
-+
get-stderr: func
get-stderr: func
Return values
-
- own<
output-stream
>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
----
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
-
- option<own<
terminal-input
>>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
----
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
-
- option<own<
terminal-output
>>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
----
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
-
- option<own<
terminal-output
>>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
-#### `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
+has occured.pollable
which will resolve once the specified instant -occured.Params
Return values
-
- own<
pollable
>-
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
-
- own<
pollable
>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
-
- -
seconds
:u64
- +
nanoseconds
:u32
- +
seconds
:u64
nanoseconds
:u32
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. -+
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
-#### `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
-
- - +
The type of the descriptor or file is unknown or is different from any of the other types specified.
- - +
The descriptor refers to a block device inode.
- - +
The descriptor refers to a character device inode.
- - +
The descriptor refers to a directory inode.
- - +
The descriptor refers to a named pipe.
- - +
The file refers to a symbolic link inode.
- - +
The descriptor refers to a regular file inode.
- - +
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 mode: Data can be read.
- - +
Write mode: Data can be written to.
- - +
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.
- - +
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.
- - +
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.
- - +
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 file if it does not exist, similar to `O_CREAT` in POSIX.
- - +
Fail if not a directory, similar to `O_DIRECTORY` in POSIX.
- - +
Fail if file already exists, similar to `O_EXCL` in POSIX.
- - +
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
-
- - +
type
:descriptor-type
File type.
- - +
Number of hard links to the file.
- - +
size
:filesize
For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link.
- -
+
data-access-timestamp
: option<datetime
>
data-access-timestamp
: option<datetime
>Last data access timestamp.
If the
option
is none, the platform doesn't maintain an access timestamp for this file.- -
+
data-modification-timestamp
: option<datetime
>
data-modification-timestamp
: option<datetime
>Last data modification timestamp.
If the
option
is none, the platform doesn't maintain a modification timestamp for this file.- -
+
status-change-timestamp
: option<datetime
>
status-change-timestamp
: option<datetime
>Last file status-change timestamp.
If the
option
is none, the platform doesn't maintain a status-change timestamp for this file.+
variant new-timestamp
variant new-timestamp
When setting a timestamp, this gives the value to set it to.
Variant Cases
-
- - +
Leave the timestamp set to its previous value.
- - +
Set the timestamp to the current time of the system clock associated with the filesystem.
- - +
timestamp
:datetime
Set the timestamp to the given value.
+
record directory-entry
record directory-entry
A directory entry.
Record Fields
-
- - +
type
:descriptor-type
The type of the file referred to by this directory entry.
- -
+
name
:string
The name of the object.
+
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
-
- - +
Permission denied, similar to `EACCES` in POSIX.
- - +
Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.
- - +
Connection already in progress, similar to `EALREADY` in POSIX.
- - +
Bad descriptor, similar to `EBADF` in POSIX.
- - +
Device or resource busy, similar to `EBUSY` in POSIX.
- - +
Resource deadlock would occur, similar to `EDEADLK` in POSIX.
- - +
Storage quota exceeded, similar to `EDQUOT` in POSIX.
- - +
File exists, similar to `EEXIST` in POSIX.
- - +
File too large, similar to `EFBIG` in POSIX.
- - +
Illegal byte sequence, similar to `EILSEQ` in POSIX.
- - +
Operation in progress, similar to `EINPROGRESS` in POSIX.
- - +
Interrupted function, similar to `EINTR` in POSIX.
- - +
Invalid argument, similar to `EINVAL` in POSIX.
- - +
I/O error, similar to `EIO` in POSIX.
- - +
Is a directory, similar to `EISDIR` in POSIX.
- - +
Too many levels of symbolic links, similar to `ELOOP` in POSIX.
- - +
Too many links, similar to `EMLINK` in POSIX.
- - +
Message too large, similar to `EMSGSIZE` in POSIX.
- - +
Filename too long, similar to `ENAMETOOLONG` in POSIX.
- - +
No such device, similar to `ENODEV` in POSIX.
- - +
No such file or directory, similar to `ENOENT` in POSIX.
- - +
No locks available, similar to `ENOLCK` in POSIX.
- - +
Not enough space, similar to `ENOMEM` in POSIX.
- - +
No space left on device, similar to `ENOSPC` in POSIX.
- - +
Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.
- - +
Directory not empty, similar to `ENOTEMPTY` in POSIX.
- - +
State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.
- - +
Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
- - +
Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.
- - +
No such device or address, similar to `ENXIO` in POSIX.
- - +
Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.
- - +
Operation not permitted, similar to `EPERM` in POSIX.
- - +
Broken pipe, similar to `EPIPE` in POSIX.
- - +
Read-only file system, similar to `EROFS` in POSIX.
- - +
Invalid seek, similar to `ESPIPE` in POSIX.
- - +
Text file busy, similar to `ETXTBSY` in POSIX.
- - +
Cross-device link, similar to `EXDEV` in POSIX.
+
enum advice
enum advice
File or memory access pattern advisory information.
Enum Cases
-
- - +
The application has no advice to give on its behavior with respect to the specified data.
- - +
The application expects to access the specified data sequentially from lower offsets to higher offsets.
- - +
The application expects to access the specified data in a random order.
- - +
The application expects to access the specified data in the near future.
- - +
The application expects that it will not access the specified data in the near future.
- - +
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
64 bits of a 128-bit hash value.
- -
+
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 toread
in POSIX.Params
-
- -
self
: borrow<descriptor
>- +
offset
:filesize
- +
self
: borrow<descriptor
>offset
:filesize
Return values
-
-- result<own<
+input-stream
>,error-code
>- result<own<
input-stream
>,error-code
>+
[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 towrite
in POSIX.Params
-
- -
self
: borrow<descriptor
>- +
offset
:filesize
- +
self
: borrow<descriptor
>offset
:filesize
Return values
-
-- result<own<
+output-stream
>,error-code
>- result<own<
output-stream
>,error-code
>+
[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 towrite
withO_APPEND
in in POSIX.Params
-
- +
self
: borrow<descriptor
>self
: borrow<descriptor
>Return values
-
-- result<own<
+output-stream
>,error-code
>- result<own<
output-stream
>,error-code
>+
[method]descriptor.advise: func
[method]descriptor.advise: func
Provide file advisory information on a descriptor.
This is similar to
posix_fadvise
in POSIX.Params
-
- -
self
: borrow<descriptor
>- -
offset
:filesize
- -
length
:filesize
- +
advice
:advice
- +
self
: borrow<descriptor
>- +
offset
:filesize
- +
length
:filesize
advice
:advice
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
-
- +
self
: borrow<descriptor
>self
: borrow<descriptor
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 fromfdstat_get
in earlier versions of WASI.Params
-
- +
self
: borrow<descriptor
>self
: borrow<descriptor
>Return values
-
-- result<
+descriptor-flags
,error-code
>- result<
descriptor-flags
,error-code
>+
[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
@@ -1216,40 +1215,40 @@ bytype
field of thefd-stat
returned bystat
,stat-at
and similar.fstat
in POSIX. fromfdstat_get
in earlier versions of WASI.Params
-
- +
self
: borrow<descriptor
>self
: borrow<descriptor
>Return values
-
-- result<
+descriptor-type
,error-code
>- result<
descriptor-type
,error-code
>+
[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
-
- -
self
: borrow<descriptor
>- +
size
:filesize
- +
self
: borrow<descriptor
>size
:filesize
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
-
- -
self
: borrow<descriptor
>- -
data-access-timestamp
:new-timestamp
- +
data-modification-timestamp
:new-timestamp
- +
self
: borrow<descriptor
>- +
data-access-timestamp
:new-timestamp
data-modification-timestamp
:new-timestamp
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
-
- -
self
: borrow<descriptor
>- -
length
:filesize
- +
offset
:filesize
- +
self
: borrow<descriptor
>- +
length
:filesize
offset
:filesize
Return values
-
-- result<(list<
+u8
>,bool
),error-code
>- result<(list<
u8
>,bool
),error-code
>+
[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
-
- -
self
: borrow<descriptor
>- -
buffer
: list<u8
>- +
offset
:filesize
- +
self
: borrow<descriptor
>- +
buffer
: list<u8
>offset
:filesize
Return values
-
-- result<
+filesize
,error-code
>- result<
filesize
,error-code
>+
[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
-
- +
self
: borrow<descriptor
>self
: borrow<descriptor
>Return values
-
-- result<own<
+directory-entry-stream
>,error-code
>- result<own<
directory-entry-stream
>,error-code
>+
[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
-
- +
self
: borrow<descriptor
>self
: borrow<descriptor
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]descriptor.create-directory-at: func
[method]descriptor.create-directory-at: func
Create a directory.
Note: This is similar to
mkdirat
in POSIX.Params
-
- -
self
: borrow<descriptor
>- +
path
:string
- +
self
: borrow<descriptor
>path
:string
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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, usemetadata-hash
.Note: This was called
fd_filestat_get
in earlier versions of WASI.Params
-
- +
self
: borrow<descriptor
>self
: borrow<descriptor
>Return values
-
-- result<
+descriptor-stat
,error-code
>- result<
descriptor-stat
,error-code
>+
[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 thestat
description for a @@ -1350,47 +1349,47 @@ discussion of alternatives.Note: This was called
path_filestat_get
in earlier versions of WASI.Params
-
- -
self
: borrow<descriptor
>- -
path-flags
:path-flags
- +
path
:string
- +
self
: borrow<descriptor
>- +
path-flags
:path-flags
path
:string
Return values
-
-- result<
+descriptor-stat
,error-code
>- result<
descriptor-stat
,error-code
>+
[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
-
- -
self
: borrow<descriptor
>- -
path-flags
:path-flags
- -
path
:string
- -
data-access-timestamp
:new-timestamp
- +
data-modification-timestamp
:new-timestamp
- +
self
: borrow<descriptor
>- +
path-flags
:path-flags
- +
path
:string
- +
data-access-timestamp
:new-timestamp
data-modification-timestamp
:new-timestamp
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]descriptor.link-at: func
[method]descriptor.link-at: func
Create a hard link.
Note: This is similar to
linkat
in POSIX.Params
-
- -
self
: borrow<descriptor
>- -
old-path-flags
:path-flags
- -
old-path
:string
- -
new-descriptor
: borrow<descriptor
>- +
new-path
:string
- +
self
: borrow<descriptor
>- +
old-path-flags
:path-flags
- +
old-path
:string
- +
new-descriptor
: borrow<descriptor
>new-path
:string
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
orcreate
, and the base descriptor dNote: This is similar to
openat
in POSIX.Params
-
- -
self
: borrow<descriptor
>- -
path-flags
:path-flags
- -
path
:string
- -
open-flags
:open-flags
- +
flags
:descriptor-flags
- +
self
: borrow<descriptor
>- +
path-flags
:path-flags
- +
path
:string
- +
open-flags
:open-flags
flags
:descriptor-flags
Return values
-
-- result<own<
+descriptor
>,error-code
>- result<own<
descriptor
>,error-code
>+
[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
-
- -
self
: borrow<descriptor
>- +
path
:string
- +
self
: borrow<descriptor
>path
:string
Return values
-
-- result<
+string
,error-code
>- result<
string
,error-code
>+
[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
-
- -
self
: borrow<descriptor
>- +
path
:string
- +
self
: borrow<descriptor
>path
:string
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]descriptor.rename-at: func
[method]descriptor.rename-at: func
Rename a filesystem object.
Note: This is similar to
renameat
in POSIX.Params
-
- -
self
: borrow<descriptor
>- -
old-path
:string
- -
new-descriptor
: borrow<descriptor
>- +
new-path
:string
- +
self
: borrow<descriptor
>- +
old-path
:string
- +
new-descriptor
: borrow<descriptor
>new-path
:string
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 witherror-code::not-permitted
.Note: This is similar to
symlinkat
in POSIX.Params
-
- -
self
: borrow<descriptor
>- -
old-path
:string
- +
new-path
:string
- +
self
: borrow<descriptor
>- +
old-path
:string
new-path
:string
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 tounlinkat(fd, path, 0)
in POSIX.Params
-
- -
self
: borrow<descriptor
>- +
path
:string
- +
self
: borrow<descriptor
>path
:string
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
ord_ino
) numbers. @@ -1494,14 +1493,14 @@ wasi-filesystem does not expose device and inode numbers, so this function may be used instead.Params
-
- -
self
: borrow<descriptor
>- +
other
: borrow<descriptor
>- +
self
: borrow<descriptor
>other
: borrow<descriptor
>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 @@ -1521,37 +1520,37 @@ computed hash.
However, none of these is required.
Params
-
- +
self
: borrow<descriptor
>self
: borrow<descriptor
>Return values
-
-- result<
+metadata-hash-value
,error-code
>- result<
metadata-hash-value
,error-code
>+
[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
-
- -
self
: borrow<descriptor
>- -
path-flags
:path-flags
- +
path
:string
- +
self
: borrow<descriptor
>- +
path-flags
:path-flags
path
:string
Return values
-
-- result<
+metadata-hash-value
,error-code
>- result<
metadata-hash-value
,error-code
>+
[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
-
- +
self
: borrow<directory-entry-stream
>self
: borrow<directory-entry-stream
>Return values
-
-- result<option<
+directory-entry
>,error-code
>- result<option<
directory-entry
>,error-code
>+
filesystem-error-code: func
filesystem-error-code: func
Attempts to extract a filesystem-related
error-code
from the streamerror
provided.Stream operations which return
errors are filesystem-related errors.stream-error::last-operation-failed
@@ -1562,34 +1561,34 @@ filesystem-related information about the error to return.Params
Return values
-
- option<
error-code
>Import interface wasi:filesystem/preopens@0.2.0
+Import interface wasi:filesystem/preopens@0.2.0
Types
-+
type descriptor
type descriptor
----
Functions
-+
get-directories: func
get-directories: func
Return the set of preopened directories, and their path.
Return values
-
- list<(own<
descriptor
>,string
)>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 error
- - +
Access denied.
POSIX equivalent: EACCES, EPERM
- - +
The operation is not supported.
POSIX equivalent: EOPNOTSUPP
- - +
One of the arguments is invalid.
POSIX equivalent: EINVAL
- - +
Not enough memory to complete the operation.
POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
- - +
The operation timed out before it could finish completely.
- - +
This operation is incompatible with another asynchronous operation that is already in progress.
POSIX equivalent: EALREADY
- - +
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
future
s are natively supported.- - +
The operation has been aborted because it could not be completed immediately.
Note: this is scheduled to be removed when
future
s are natively supported.- - +
The operation is not valid in the socket's current state.
- - +
A new socket resource could not be created because of a system limit.
- - +
A bind operation failed because the provided address is not an address that the `network` can bind to.
- - +
A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.
- - +
The remote address is not reachable
- - +
The TCP connection was forcefully rejected
- - +
The TCP connection was reset.
- - +
A TCP connection was aborted.
- - +
The size of a datagram sent to a UDP socket exceeded the maximum supported size.
- - +
Name does not exist or has no suitable associated IP addresses.
- - +
A temporary failure in name resolution occurred.
- - +
A permanent failure in name resolution occurred.
+
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
-
-- -
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
-
-- -
ipv4
:ipv4-address
- +
ipv6
:ipv6-address
- +
ipv4
:ipv4-address
ipv6
:ipv6-address
+
record ipv4-socket-address
record ipv4-socket-address
Record Fields
-
- -
+
port
:u16
sin_port
- - +
address
:ipv4-address
sin_addr
+
record ipv6-socket-address
record ipv6-socket-address
Record Fields
-
- -
+
port
:u16
sin6_port
- -
+
flow-info
:u32
sin6_flowinfo
- - +
address
:ipv6-address
sin6_addr
- -
+
scope-id
:u32
sin6_scope_id
+
variant ip-socket-address
variant ip-socket-address
Variant Cases
-
-- -
ipv4
:ipv4-socket-address
- +
ipv6
:ipv6-socket-address
- +
ipv4
:ipv4-socket-address
ipv6
:ipv6-socket-address
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
----
Functions
-+
instance-network: func
instance-network: func
Get a handle to the default network.
Return values
-
- own<
network
>Import interface wasi:sockets/udp@0.2.0
+Import interface wasi:sockets/udp@0.2.0
Types
-+
type pollable
type 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
>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 ofrecvfrom
.+
record outgoing-datagram
record outgoing-datagram
A datagram to be sent out.
Record Fields
-
- -
+
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 tosendto
.+
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 nativeParams
-
- -
self
: borrow<udp-socket
>- -
network
: borrow<network
>- +
local-address
:ip-socket-address
- +
self
: borrow<udp-socket
>- +
network
: borrow<network
>local-address
:ip-socket-address
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]udp-socket.finish-bind: func
[method]udp-socket.finish-bind: func
Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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. Thelocal-address
may be updated as well, @@ -1936,14 +1935,14 @@ if (remote_address is Some) {Params
-
- -
self
: borrow<udp-socket
>- +
remote-address
: option<ip-socket-address
>- +
self
: borrow<udp-socket
>remote-address
: option<ip-socket-address
>Return values
-
-- result<(own<
+incoming-datagram-stream
>, own<outgoing-datagram-stream
>),error-code
>- result<(own<
incoming-datagram-stream
>, own<outgoing-datagram-stream
>),error-code
>+
[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 byaddress
is unspecified.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[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
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[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
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>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 byaddress
is unspecified.Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u8
,error-code
>- result<
u8
,error-code
>+
[method]udp-socket.set-unicast-hop-limit: func
[method]udp-socket.set-unicast-hop-limit: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u8
- +
self
: borrow<udp-socket
>value
:u8
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]udp-socket.set-receive-buffer-size: func
[method]udp-socket.set-receive-buffer-size: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u64
- +
self
: borrow<udp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]udp-socket.send-buffer-size: func
[method]udp-socket.send-buffer-size: func
Params
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]udp-socket.set-send-buffer-size: func
[method]udp-socket.set-send-buffer-size: func
Params
-
- -
self
: borrow<udp-socket
>- +
value
:u64
- +
self
: borrow<udp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
-
- +
self
: borrow<udp-socket
>self
: borrow<udp-socket
>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
@@ -2114,26 +2113,26 @@ This function never returnsmax-results
datagrams on the socket without blocking. The returned list may contain fewer elements than requested, but never more.error(would-block)
.Params
-
- -
self
: borrow<incoming-datagram-stream
>- +
max-results
:u64
- +
self
: borrow<incoming-datagram-stream
>max-results
:u64
Return values
-
-- result<list<
+incoming-datagram
>,error-code
>- result<list<
incoming-datagram
>,error-code
>+
[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
-
- +
self
: borrow<incoming-datagram-stream
>self
: borrow<incoming-datagram-stream
>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. Callingsend
with more datagrams than this function has @@ -2144,13 +2143,13 @@ error.Never returns
would-block
.Params
-
- +
self
: borrow<outgoing-datagram-stream
>self
: borrow<outgoing-datagram-stream
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[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 @@ eithercheck-send
was not called ordatagrams
containsParams
-
- -
self
: borrow<outgoing-datagram-stream
>- +
datagrams
: list<outgoing-datagram
>- +
self
: borrow<outgoing-datagram-stream
>datagrams
: list<outgoing-datagram
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[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
-
- +
self
: borrow<outgoing-datagram-stream
>self
: borrow<outgoing-datagram-stream
>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
-#### `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
@@ -2243,56 +2242,56 @@ the socket is effectively an in-memory configuration object, unable to communicasocket(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.Params
-
- +
address-family
:ip-address-family
address-family
:ip-address-family
Return values
-
- result<own<
udp-socket
>,error-code
>Import interface wasi:sockets/tcp@0.2.0
+Import interface wasi:sockets/tcp@0.2.0
Types
-+
type input-stream
type 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
-
- - +
Similar to `SHUT_RD` in POSIX.
- - +
Similar to `SHUT_WR` in POSIX.
- - +
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:
@@ -2304,8 +2303,8 @@ the socket is effectively an in-memory configuration object, unable to communica
connect-in-progress
connected
- +See https://github.com/WebAssembly/wasi-sockets/blob/main/TcpSocketOperationalSemantics.md +for more information.
closed
-See https://github.com/WebAssembly/wasi-sockets/TcpSocketOperationalSemantics.md -for a 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. @@ -2314,7 +2313,7 @@ the term "bound" without backticks it actually means: in thebou
network::error-code
type, TCP socket methods may always returnerror(invalid-state)
when in theclosed
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 nativeParams
-
- -
self
: borrow<tcp-socket
>- -
network
: borrow<network
>- +
local-address
:ip-socket-address
- +
self
: borrow<tcp-socket
>- +
network
: borrow<network
>local-address
:ip-socket-address
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-bind: func
[method]tcp-socket.finish-bind: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 @@ theSO_ERROR
socket option, in case the poll signaled readiness.Params
-
- -
self
: borrow<tcp-socket
>- -
network
: borrow<network
>- +
remote-address
:ip-socket-address
- +
self
: borrow<tcp-socket
>- +
network
: borrow<network
>remote-address
:ip-socket-address
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-connect: func
[method]tcp-socket.finish-connect: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<(own<
+input-stream
>, own<output-stream
>),error-code
>- result<(own<
input-stream
>, own<output-stream
>),error-code
>+
[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 nativeParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.finish-listen: func
[method]tcp-socket.finish-listen: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<(own<
+tcp-socket
>, own<input-stream
>, own<output-stream
>),error-code
>- result<(own<
tcp-socket
>, own<input-stream
>, own<output-stream
>),error-code
>+
[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 byaddress
is unspecified.Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+ip-socket-address
,error-code
>- result<
ip-socket-address
,error-code
>+
[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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-+
[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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>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
@@ -2593,14 +2592,14 @@ Any other value will never cause an error, but it might be silently clamped and/invalid-argument
error is returned. Any other value will never cause an error, but it might be silently clamped and/or rounded.Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 falsEquivalent to the SO_KEEPALIVE socket option.
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+bool
,error-code
>- result<
bool
,error-code
>+
[method]tcp-socket.set-keep-alive-enabled: func
[method]tcp-socket.set-keep-alive-enabled: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:bool
- +
self
: borrow<tcp-socket
>value
:bool
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+duration
,error-code
>- result<
duration
,error-code
>+
[method]tcp-socket.set-keep-alive-idle-time: func
[method]tcp-socket.set-keep-alive-idle-time: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:duration
- +
self
: borrow<tcp-socket
>value
:duration
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+duration
,error-code
>- result<
duration
,error-code
>+
[method]tcp-socket.set-keep-alive-interval: func
[method]tcp-socket.set-keep-alive-interval: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:duration
- +
self
: borrow<tcp-socket
>value
:duration
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u32
,error-code
>- result<
u32
,error-code
>+
[method]tcp-socket.set-keep-alive-count: func
[method]tcp-socket.set-keep-alive-count: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u32
- +
self
: borrow<tcp-socket
>value
:u32
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u8
,error-code
>- result<
u8
,error-code
>+
[method]tcp-socket.set-hop-limit: func
[method]tcp-socket.set-hop-limit: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u8
- +
self
: borrow<tcp-socket
>value
:u8
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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 differentParams
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]tcp-socket.set-receive-buffer-size: func
[method]tcp-socket.set-receive-buffer-size: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[method]tcp-socket.send-buffer-size: func
[method]tcp-socket.send-buffer-size: func
Params
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-
-- result<
+u64
,error-code
>- result<
u64
,error-code
>+
[method]tcp-socket.set-send-buffer-size: func
[method]tcp-socket.set-send-buffer-size: func
Params
-
- -
self
: borrow<tcp-socket
>- +
value
:u64
- +
self
: borrow<tcp-socket
>value
:u64
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>+
[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
in progress at the time of callingfinish-bind
,finish-listen
,finish-connect
oraccept
@@ -2794,19 +2793,19 @@ their success or failure, after which the method can be retried.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
-
- +
self
: borrow<tcp-socket
>self
: borrow<tcp-socket
>Return values
-+
[method]tcp-socket.shutdown: func
[method]tcp-socket.shutdown: func
Initiate a graceful shutdown.
-
- associated with this socket will be closed and a FIN packet will be sent.
receive
: The socket is not expecting to receive any data from @@ -2817,7 +2816,7 @@ this method will be discarded.both
: Same effect asreceive
&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 returnsok
.Params
-
- -
self
: borrow<tcp-socket
>- +
shutdown-type
:shutdown-type
- +
self
: borrow<tcp-socket
>shutdown-type
:shutdown-type
Return values
-
-- result<_,
+error-code
>- result<_,
error-code
>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
-#### `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
@@ -2879,31 +2878,31 @@ is called, the socket is effectively an in-memory configuration object, unable tsocket(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.Params
-
- +
address-family
:ip-address-family
address-family
:ip-address-family
Return values
-
- result<own<
tcp-socket
>,error-code
>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
-#### `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
-
- result<own<
resolve-address-stream
>,error-code
>+
[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
-
- +
self
: borrow<resolve-address-stream
>self
: borrow<resolve-address-stream
>Return values
-
-- result<option<
+ip-address
>,error-code
>- result<option<
ip-address
>,error-code
>+
[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
-
- +
self
: borrow<resolve-address-stream
>self
: borrow<resolve-address-stream
>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
-+
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
@@ -2998,13 +2997,13 @@ represented as aget-random-bytes
, represented as au64
.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
-+
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
@@ -3027,13 +3026,13 @@ a long period. -get-insecure-random-bytes
, represented as au64
.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/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