Expand description
Raw API bindings to the WebAssembly System Interface (WASI)
This crate provides Rust API bindings to WASI APIs. All WASI APIs are
exported from this crate and provided with the appropriate type signatures.
This crate is entirely procedurally generated from the *.witx
files that
describe the WASI API.
§WASI API Version
The WASI API is evolving over time. It is both gaining new features as well as tweaking the ABI of existing features. As a result it’s important to understand what version of this crate you’re using and how it relates to the WASI version of the spec.
The WASI specification is organized into phases where there is a snapshot
at any one point in time describing the current state of the specification.
This crate implements a particular snapshot. You can find the snapshot
version implemented in this crate in the build metadata of the crate
version number. For example something like 0.9.0+wasi-snapshot-preview1
means that this crate’s own personal version is 0.9.0 and it implements the
wasi-snapshot-preview1
snapshot. A major release of this crate (i.e.
bumping the “0.9.0”) is expected whenever the generated code changes
or a new WASI snapshot is used.
§Crate Features
This crate supports one feature, std
, which implements the standard
Error
trait for the exported [Error
] type in this crate. This is
enabled by default but can be disabled to make the library no_std
compatible.
Modules§
Structs§
- Advice
- Ciovec
- Clockid
- Dirent
- Errno
- Event
- Event
FdReadwrite - Eventtype
- Fdstat
- Filestat
- Filetype
- Iovec
- Preopentype
- Prestat
- Prestat
Dir - Signal
- Subscription
- Subscription
Clock - Subscription
FdReadwrite - SubscriptionU
- Whence
Constants§
- ADVICE_
DONTNEED - The application expects that it will not access the specified data in the near future.
- ADVICE_
NOREUSE - The application expects to access the specified data once and then not reuse it thereafter.
- ADVICE_
NORMAL - The application has no advice to give on its behavior with respect to the specified data.
- ADVICE_
RANDOM - The application expects to access the specified data in a random order.
- ADVICE_
SEQUENTIAL - The application expects to access the specified data sequentially from lower offsets to higher offsets.
- ADVICE_
WILLNEED - The application expects to access the specified data in the near future.
- CLOCKID_
MONOTONIC - The store-wide monotonic clock, which is defined as a clock measuring real time, whose value cannot be adjusted and which cannot have negative clock jumps. The epoch of this clock is undefined. The absolute time value of this clock therefore has no meaning.
- CLOCKID_
PROCESS_ CPUTIME_ ID - The CPU-time clock associated with the current process.
- CLOCKID_
REALTIME - The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z.
- CLOCKID_
THREAD_ CPUTIME_ ID - The CPU-time clock associated with the current thread.
- DIRCOOKIE_
START - Special
Dircookie
value indicating the start of a directory. - ERRNO_
2BIG - Argument list too long.
- ERRNO_
ACCES - Permission denied.
- ERRNO_
ADDRINUSE - Address in use.
- ERRNO_
ADDRNOTAVAIL - Address not available.
- ERRNO_
AFNOSUPPORT - Address family not supported.
- ERRNO_
AGAIN - Resource unavailable, or operation would block.
- ERRNO_
ALREADY - Connection already in progress.
- ERRNO_
BADF - Bad file descriptor.
- ERRNO_
BADMSG - Bad message.
- ERRNO_
BUSY - Device or resource busy.
- ERRNO_
CANCELED - Operation canceled.
- ERRNO_
CHILD - No child processes.
- ERRNO_
CONNABORTED - Connection aborted.
- ERRNO_
CONNREFUSED - Connection refused.
- ERRNO_
CONNRESET - Connection reset.
- ERRNO_
DEADLK - Resource deadlock would occur.
- ERRNO_
DESTADDRREQ - Destination address required.
- ERRNO_
DOM - Mathematics argument out of domain of function.
- ERRNO_
DQUOT - Reserved.
- ERRNO_
EXIST - File exists.
- ERRNO_
FAULT - Bad address.
- ERRNO_
FBIG - File too large.
- ERRNO_
HOSTUNREACH - Host is unreachable.
- ERRNO_
IDRM - Identifier removed.
- ERRNO_
ILSEQ - Illegal byte sequence.
- ERRNO_
INPROGRESS - Operation in progress.
- ERRNO_
INTR - Interrupted function.
- ERRNO_
INVAL - Invalid argument.
- ERRNO_
IO - I/O error.
- ERRNO_
ISCONN - Socket is connected.
- ERRNO_
ISDIR - Is a directory.
- ERRNO_
LOOP - Too many levels of symbolic links.
- ERRNO_
MFILE - File descriptor value too large.
- ERRNO_
MLINK - Too many links.
- ERRNO_
MSGSIZE - Message too large.
- ERRNO_
MULTIHOP - Reserved.
- ERRNO_
NAMETOOLONG - Filename too long.
- ERRNO_
NETDOWN - Network is down.
- ERRNO_
NETRESET - Connection aborted by network.
- ERRNO_
NETUNREACH - Network unreachable.
- ERRNO_
NFILE - Too many files open in system.
- ERRNO_
NOBUFS - No buffer space available.
- ERRNO_
NODEV - No such device.
- ERRNO_
NOENT - No such file or directory.
- ERRNO_
NOEXEC - Executable file format error.
- ERRNO_
NOLCK - No locks available.
- ERRNO_
NOLINK - Reserved.
- ERRNO_
NOMEM - Not enough space.
- ERRNO_
NOMSG - No message of the desired type.
- ERRNO_
NOPROTOOPT - Protocol not available.
- ERRNO_
NOSPC - No space left on device.
- ERRNO_
NOSYS - Function not supported.
- ERRNO_
NOTCAPABLE - Extension: Capabilities insufficient.
- ERRNO_
NOTCONN - The socket is not connected.
- ERRNO_
NOTDIR - Not a directory or a symbolic link to a directory.
- ERRNO_
NOTEMPTY - Directory not empty.
- ERRNO_
NOTRECOVERABLE - State not recoverable.
- ERRNO_
NOTSOCK - Not a socket.
- ERRNO_
NOTSUP - Not supported, or operation not supported on socket.
- ERRNO_
NOTTY - Inappropriate I/O control operation.
- ERRNO_
NXIO - No such device or address.
- ERRNO_
OVERFLOW - Value too large to be stored in data type.
- ERRNO_
OWNERDEAD - Previous owner died.
- ERRNO_
PERM - Operation not permitted.
- ERRNO_
PIPE - Broken pipe.
- ERRNO_
PROTO - Protocol error.
- ERRNO_
PROTONOSUPPORT - Protocol not supported.
- ERRNO_
PROTOTYPE - Protocol wrong type for socket.
- ERRNO_
RANGE - Result too large.
- ERRNO_
ROFS - Read-only file system.
- ERRNO_
SPIPE - Invalid seek.
- ERRNO_
SRCH - No such process.
- ERRNO_
STALE - Reserved.
- ERRNO_
SUCCESS - No error occurred. System call completed successfully.
- ERRNO_
TIMEDOUT - Connection timed out.
- ERRNO_
TXTBSY - Text file busy.
- ERRNO_
XDEV - Cross-device link.
- EVENTRWFLAGS_
FD_ READWRITE_ HANGUP - The peer of this socket has closed or disconnected.
- EVENTTYPE_
CLOCK - The time value of clock
subscription_clock::id
has reached timestampsubscription_clock::timeout
. - EVENTTYPE_
FD_ READ - File descriptor
subscription_fd_readwrite::file_descriptor
has data available for reading. This event always triggers for regular files. - EVENTTYPE_
FD_ WRITE - File descriptor
subscription_fd_readwrite::file_descriptor
has capacity available for writing. This event always triggers for regular files. - FDFLAGS_
APPEND - Append mode: Data written to the file is always appended to the file’s end.
- FDFLAGS_
DSYNC - Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
- FDFLAGS_
NONBLOCK - Non-blocking mode.
- FDFLAGS_
RSYNC - Synchronized read I/O operations.
- FDFLAGS_
SYNC - Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file’s metadata.
- FD_
STDERR - The “standard error” descriptor number.
- FD_
STDIN - The “standard input” descriptor number.
- FD_
STDOUT - The “standard output” descriptor number.
- FILETYPE_
BLOCK_ DEVICE - The file descriptor or file refers to a block device inode.
- FILETYPE_
CHARACTER_ DEVICE - The file descriptor or file refers to a character device inode.
- FILETYPE_
DIRECTORY - The file descriptor or file refers to a directory inode.
- FILETYPE_
REGULAR_ FILE - The file descriptor or file refers to a regular file inode.
- FILETYPE_
SOCKET_ DGRAM - The file descriptor or file refers to a datagram socket.
- FILETYPE_
SOCKET_ STREAM - The file descriptor or file refers to a byte-stream socket.
- FILETYPE_
SYMBOLIC_ LINK - The file refers to a symbolic link inode.
- FILETYPE_
UNKNOWN - The type of the file descriptor or file is unknown or is different from any of the other types specified.
- FSTFLAGS_
ATIM - Adjust the last data access timestamp to the value stored in
filestat::atim
. - FSTFLAGS_
ATIM_ NOW - Adjust the last data access timestamp to the time of clock
clockid::realtime
. - FSTFLAGS_
MTIM - Adjust the last data modification timestamp to the value stored in
filestat::mtim
. - FSTFLAGS_
MTIM_ NOW - Adjust the last data modification timestamp to the time of clock
clockid::realtime
. - LOOKUPFLAGS_
SYMLINK_ FOLLOW - As long as the resolved path corresponds to a symbolic link, it is expanded.
- OFLAGS_
CREAT - Create file if it does not exist.
- OFLAGS_
DIRECTORY - Fail if not a directory.
- OFLAGS_
EXCL - Fail if file already exists.
- OFLAGS_
TRUNC - Truncate file to size 0.
- PREOPENTYPE_
DIR - A pre-opened directory.
- RIFLAGS_
RECV_ PEEK - Returns the message without removing it from the socket’s receive queue.
- RIFLAGS_
RECV_ WAITALL - On byte-stream sockets, block until the full amount of data can be returned.
- RIGHTS_
FD_ ADVISE - The right to invoke
fd_advise
. - RIGHTS_
FD_ ALLOCATE - The right to invoke
fd_allocate
. - RIGHTS_
FD_ DATASYNC - The right to invoke
fd_datasync
. Ifpath_open
is set, includes the right to invokepath_open
withfdflags::dsync
. - RIGHTS_
FD_ FDSTAT_ SET_ FLAGS - The right to invoke
fd_fdstat_set_flags
. - RIGHTS_
FD_ FILESTAT_ GET - The right to invoke
fd_filestat_get
. - RIGHTS_
FD_ FILESTAT_ SET_ SIZE - The right to invoke
fd_filestat_set_size
. - RIGHTS_
FD_ FILESTAT_ SET_ TIMES - The right to invoke
fd_filestat_set_times
. - RIGHTS_
FD_ READ - The right to invoke
fd_read
andsock_recv
. Ifrights::fd_seek
is set, includes the right to invokefd_pread
. - RIGHTS_
FD_ READDIR - The right to invoke
fd_readdir
. - RIGHTS_
FD_ SEEK - The right to invoke
fd_seek
. This flag impliesrights::fd_tell
. - RIGHTS_
FD_ SYNC - The right to invoke
fd_sync
. Ifpath_open
is set, includes the right to invokepath_open
withfdflags::rsync
andfdflags::dsync
. - RIGHTS_
FD_ TELL - The right to invoke
fd_seek
in such a way that the file offset remains unaltered (i.e.,whence::cur
with offset zero), or to invokefd_tell
. - RIGHTS_
FD_ WRITE - The right to invoke
fd_write
andsock_send
. Ifrights::fd_seek
is set, includes the right to invokefd_pwrite
. - RIGHTS_
PATH_ CREATE_ DIRECTORY - The right to invoke
path_create_directory
. - RIGHTS_
PATH_ CREATE_ FILE - If
path_open
is set, the right to invokepath_open
withoflags::creat
. - RIGHTS_
PATH_ FILESTAT_ GET - The right to invoke
path_filestat_get
. - RIGHTS_
PATH_ FILESTAT_ SET_ SIZE - The right to change a file’s size (there is no
path_filestat_set_size
). Ifpath_open
is set, includes the right to invokepath_open
withoflags::trunc
. - RIGHTS_
PATH_ FILESTAT_ SET_ TIMES - The right to invoke
path_filestat_set_times
. - RIGHTS_
PATH_ LINK_ SOURCE - The right to invoke
path_link
with the file descriptor as the source directory. - RIGHTS_
PATH_ LINK_ TARGET - The right to invoke
path_link
with the file descriptor as the target directory. - RIGHTS_
PATH_ OPEN - The right to invoke
path_open
. - RIGHTS_
PATH_ READLINK - The right to invoke
path_readlink
. - RIGHTS_
PATH_ REMOVE_ DIRECTORY - The right to invoke
path_remove_directory
. - RIGHTS_
PATH_ RENAME_ SOURCE - The right to invoke
path_rename
with the file descriptor as the source directory. - RIGHTS_
PATH_ RENAME_ TARGET - The right to invoke
path_rename
with the file descriptor as the target directory. - RIGHTS_
PATH_ SYMLINK - The right to invoke
path_symlink
. - RIGHTS_
PATH_ UNLINK_ FILE - The right to invoke
path_unlink_file
. - RIGHTS_
POLL_ FD_ READWRITE - If
rights::fd_read
is set, includes the right to invokepoll_oneoff
to subscribe toeventtype::fd_read
. Ifrights::fd_write
is set, includes the right to invokepoll_oneoff
to subscribe toeventtype::fd_write
. - RIGHTS_
SOCK_ ACCEPT - The right to invoke
sock_accept
. - RIGHTS_
SOCK_ SHUTDOWN - The right to invoke
sock_shutdown
. - ROFLAGS_
RECV_ DATA_ TRUNCATED - Returned by
sock_recv
: Message data has been truncated. - SDFLAGS_
RD - Disables further receive operations.
- SDFLAGS_
WR - Disables further send operations.
- SIGNAL_
ABRT - Process abort signal. Action: Terminates the process.
- SIGNAL_
ALRM - Alarm clock. Action: Terminates the process.
- SIGNAL_
BUS - Access to an undefined portion of a memory object. Action: Terminates the process.
- SIGNAL_
CHLD - Child process terminated, stopped, or continued. Action: Ignored.
- SIGNAL_
CONT - Continue executing, if stopped. Action: Continues executing, if stopped.
- SIGNAL_
FPE - Erroneous arithmetic operation. Action: Terminates the process.
- SIGNAL_
HUP - Hangup. Action: Terminates the process.
- SIGNAL_
ILL - Illegal instruction. Action: Terminates the process.
- SIGNAL_
INT - Terminate interrupt signal. Action: Terminates the process.
- SIGNAL_
KILL - Kill. Action: Terminates the process.
- SIGNAL_
NONE - No signal. Note that POSIX has special semantics for
kill(pid, 0)
, so this value is reserved. - SIGNAL_
PIPE - Write on a pipe with no one to read it. Action: Ignored.
- SIGNAL_
POLL - I/O possible. Action: Terminates the process.
- SIGNAL_
PROF - Profiling timer expired. Action: Terminates the process.
- SIGNAL_
PWR - Power failure. Action: Terminates the process.
- SIGNAL_
QUIT - Terminal quit signal. Action: Terminates the process.
- SIGNAL_
SEGV - Invalid memory reference. Action: Terminates the process.
- SIGNAL_
STOP - Stop executing. Action: Stops executing.
- SIGNAL_
SYS - Bad system call. Action: Terminates the process.
- SIGNAL_
TERM - Termination signal. Action: Terminates the process.
- SIGNAL_
TRAP - Trace/breakpoint trap. Action: Terminates the process.
- SIGNAL_
TSTP - Terminal stop signal. Action: Stops executing.
- SIGNAL_
TTIN - Background process attempting read. Action: Stops executing.
- SIGNAL_
TTOU - Background process attempting write. Action: Stops executing.
- SIGNAL_
URG - High bandwidth data is available at a socket. Action: Ignored.
- SIGNAL_
USR1 - User-defined signal 1. Action: Terminates the process.
- SIGNAL_
USR2 - User-defined signal 2. Action: Terminates the process.
- SIGNAL_
VTALRM - Virtual timer expired. Action: Terminates the process.
- SIGNAL_
WINCH - Window changed. Action: Ignored.
- SIGNAL_
XCPU - CPU time limit exceeded. Action: Terminates the process.
- SIGNAL_
XFSZ - File size limit exceeded. Action: Terminates the process.
- SUBCLOCKFLAGS_
SUBSCRIPTION_ CLOCK_ ABSTIME - If set, treat the timestamp provided in
subscription_clock::timeout
as an absolute timestamp of clocksubscription_clock::id
. If clear, treat the timestamp provided insubscription_clock::timeout
relative to the current time value of clocksubscription_clock::id
. - WHENCE_
CUR - Seek relative to current position.
- WHENCE_
END - Seek relative to end-of-file.
- WHENCE_
SET - Seek relative to start-of-file.
Functions§
- args_
get ⚠ - Read command-line argument data.
The size of the array should match that returned by
args_sizes_get
. Each argument is expected to be\0
terminated. - args_
sizes_ ⚠get - Return command-line argument data sizes.
- clock_
res_ ⚠get - Return the resolution of a clock.
Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks,
return
errno::inval
. Note: This is similar toclock_getres
in POSIX. - clock_
time_ ⚠get - Return the time value of a clock.
Note: This is similar to
clock_gettime
in POSIX. - environ_
get ⚠ - Read environment variable data.
The sizes of the buffers should match that returned by
environ_sizes_get
. Key/value pairs are expected to be joined with=
s, and terminated with\0
s. - environ_
sizes_ ⚠get - Return environment variable data sizes.
- fd_
advise ⚠ - Provide file advisory information on a file descriptor.
Note: This is similar to
posix_fadvise
in POSIX. - fd_
allocate ⚠ - Force the allocation of space in a file.
Note: This is similar to
posix_fallocate
in POSIX. - fd_
close ⚠ - Close a file descriptor.
Note: This is similar to
close
in POSIX. - fd_
datasync ⚠ - Synchronize the data of a file to disk.
Note: This is similar to
fdatasync
in POSIX. - fd_
fdstat_ ⚠get - Get the attributes of a file descriptor.
Note: This returns similar flags to
fsync(fd, F_GETFL)
in POSIX, as well as additional fields. - fd_
fdstat_ ⚠set_ flags - Adjust the flags associated with a file descriptor.
Note: This is similar to
fcntl(fd, F_SETFL, flags)
in POSIX. - fd_
fdstat_ ⚠set_ rights - Adjust the rights associated with a file descriptor.
This can only be used to remove rights, and returns
errno::notcapable
if called in a way that would attempt to add rights - fd_
filestat_ ⚠get - Return the attributes of an open file.
- fd_
filestat_ ⚠set_ size - Adjust the size of an open file. If this increases the file’s size, the extra bytes are filled with zeros.
Note: This is similar to
ftruncate
in POSIX. - fd_
filestat_ ⚠set_ times - Adjust the timestamps of an open file or directory.
Note: This is similar to
futimens
in POSIX. - fd_
pread ⚠ - Read from a file descriptor, without using and updating the file descriptor’s offset.
Note: This is similar to
preadv
in POSIX. - fd_
prestat_ ⚠dir_ name - Return a description of the given preopened file descriptor.
- fd_
prestat_ ⚠get - Return a description of the given preopened file descriptor.
- fd_
pwrite ⚠ - Write to a file descriptor, without using and updating the file descriptor’s offset.
Note: This is similar to
pwritev
in POSIX. - fd_read⚠
- Read from a file descriptor.
Note: This is similar to
readv
in POSIX. - fd_
readdir ⚠ - Read directory entries from a directory.
When successful, the contents of the output buffer consist of a sequence of
directory entries. Each directory entry consists of a
dirent
object, followed bydirent::d_namlen
bytes holding the name of the directory entry. This function fills the output buffer as much as possible, potentially truncating the last directory entry. This allows the caller to grow its read buffer size in case it’s too small to fit a single large directory entry, or skip the oversized directory entry. - fd_
renumber ⚠ - Atomically replace a file descriptor by renumbering another file descriptor.
Due to the strong focus on thread safety, this environment does not provide
a mechanism to duplicate or renumber a file descriptor to an arbitrary
number, like
dup2()
. This would be prone to race conditions, as an actual file descriptor with the same number could be allocated by a different thread at the same time. This function provides a way to atomically renumber file descriptors, which would disappear ifdup2()
were to be removed entirely. - fd_seek⚠
- Move the offset of a file descriptor.
Note: This is similar to
lseek
in POSIX. - fd_sync⚠
- Synchronize the data and metadata of a file to disk.
Note: This is similar to
fsync
in POSIX. - fd_tell⚠
- Return the current offset of a file descriptor.
Note: This is similar to
lseek(fd, 0, SEEK_CUR)
in POSIX. - fd_
write ⚠ - Write to a file descriptor.
Note: This is similar to
writev
in POSIX. - path_
create_ ⚠directory - Create a directory.
Note: This is similar to
mkdirat
in POSIX. - path_
filestat_ ⚠get - Return the attributes of a file or directory.
Note: This is similar to
stat
in POSIX. - path_
filestat_ ⚠set_ times - Adjust the timestamps of a file or directory.
Note: This is similar to
utimensat
in POSIX. - path_
link ⚠ - Create a hard link.
Note: This is similar to
linkat
in POSIX. - path_
open ⚠ - Open a file or directory.
The returned file descriptor is not guaranteed to be the lowest-numbered
file descriptor not currently open; it is randomized to prevent
applications from depending on making assumptions about indexes, since this
is error-prone in multi-threaded contexts. The returned file descriptor is
guaranteed to be less than 2**31.
Note: This is similar to
openat
in POSIX. - path_
readlink ⚠ - Read the contents of a symbolic link.
Note: This is similar to
readlinkat
in POSIX. - path_
remove_ ⚠directory - Remove a directory.
Return
errno::notempty
if the directory is not empty. Note: This is similar tounlinkat(fd, path, AT_REMOVEDIR)
in POSIX. - path_
rename ⚠ - Rename a file or directory.
Note: This is similar to
renameat
in POSIX. - path_
symlink ⚠ - Create a symbolic link.
Note: This is similar to
symlinkat
in POSIX. - path_
unlink_ ⚠file - Unlink a file.
Return
errno::isdir
if the path refers to a directory. Note: This is similar tounlinkat(fd, path, 0)
in POSIX. - poll_
oneoff ⚠ - Concurrently poll for the occurrence of a set of events.
- proc_
exit ⚠ - Terminate the process normally. An exit code of 0 indicates successful termination of the program. The meanings of other values is dependent on the environment.
- proc_
raise ⚠ - Send a signal to the process of the calling thread.
Note: This is similar to
raise
in POSIX. - random_
get ⚠ - Write high-quality random data into a buffer. This function blocks when the implementation is unable to immediately provide sufficient high-quality random data. This function may execute slowly, so when large mounts of random data are required, it’s advisable to use this function to seed a pseudo-random number generator, rather than to provide the random data directly.
- sched_
yield ⚠ - Temporarily yield execution of the calling thread.
Note: This is similar to
sched_yield
in POSIX. - sock_
accept ⚠ - Accept a new incoming connection.
Note: This is similar to
accept
in POSIX. - sock_
recv ⚠ - Receive a message from a socket.
Note: This is similar to
recv
in POSIX, though it also supports reading the data into multiple buffers in the manner ofreadv
. - sock_
send ⚠ - Send a message on a socket.
Note: This is similar to
send
in POSIX, though it also supports writing the data from multiple buffers in the manner ofwritev
. - sock_
shutdown ⚠ - Shut down socket send and receive channels.
Note: This is similar to
shutdown
in POSIX.
Type Aliases§
- Ciovec
Array - Device
- Dircookie
- Dirnamlen
- Eventrwflags
- Exitcode
- Fd
- Fdflags
- Filedelta
- Filesize
- Fstflags
- Inode
- Iovec
Array - Linkcount
- Lookupflags
- Oflags
- Riflags
- Rights
- Roflags
- Sdflags
- Siflags
- Size
- Subclockflags
- Timestamp
- Userdata