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

Constants

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.
The application has no advice to give on its behavior with respect to the specified data.
The application expects to access the specified data in a random order.
The application expects to access the specified data sequentially from lower offsets to higher offsets.
The application expects to access the specified data in the near future.
Uses the bincode serializer
Uses the message pack serializer
Raw binary data
the request has been aborted.
result already consumed
invalid input was supplied in the call resulting in a bad request.
bus invocation has failed
failed to compile the WAPM module.
there was an error while deserializing the request or response.
failed to fetch the WAPM module.
an internal failure has occured
the ABI is invalid for cross module calls.
the handle is not valid.
the specified WAPM module does not exist.
memory access violation
memory allocation has failed
some mandatory callbacks were not registered.
there was an error while serializing the request or response.
operation successful
this operation is not supported on this platform.
Someone has invoked something
Frees all the resources on a call
The bus process has exited
Fault has occured on one of the calls
Nothing has happened
An invocation has completed and this is the result
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.
The CPU-time clock associated with the current process.
The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z.
The CPU-time clock associated with the current thread.
Special Dircookie value indicating the start of a directory.
Argument list too long.
Permission denied.
Address in use.
Address not available.
Address family not supported.
Resource unavailable, or operation would block.
Connection already in progress.
Bad file descriptor.
Bad message.
Device or resource busy.
Operation canceled.
No child processes.
Connection aborted.
Connection refused.
Connection reset.
Resource deadlock would occur.
Destination address required.
Mathematics argument out of domain of function.
Reserved.
File exists.
Bad address.
File too large.
Host is unreachable.
Identifier removed.
Illegal byte sequence.
Operation in progress.
Interrupted function.
Invalid argument.
I/O error.
Socket is connected.
Is a directory.
Too many levels of symbolic links.
File descriptor value too large.
Too many links.
Message too large.
Filename too long.
Network is down.
Connection aborted by network.
Network unreachable.
Too many files open in system.
No buffer space available.
No such device.
No such file or directory.
Executable file format error.
No locks available.
Reserved.
Not enough space.
No message of the desired type.
Protocol not available.
No space left on device.
Function not supported.
Extension: Capabilities insufficient.
The socket is not connected.
Not a directory or a symbolic link to a directory.
Directory not empty.
State not recoverable.
Not a socket.
Not supported, or operation not supported on socket.
Inappropriate I/O control operation.
No such device or address.
Value too large to be stored in data type.
Previous owner died.
Operation not permitted.
Broken pipe.
Protocol error.
Protocol not supported.
Protocol wrong type for socket.
Result too large.
Read-only file system.
Cannot send after socket shutdown.
Invalid seek.
No such process.
Reserved.
No error occurred. System call completed successfully.
Connection timed out.
Text file busy.
Cross-device link.
Indicates if this event file description will run as a semaphore
The peer of this socket has closed or disconnected.
The time value of clock subscription_clock::id has reached timestamp subscription_clock::timeout.
File descriptor subscription_fd_readwrite::file_descriptor has data available for reading. This event always triggers for regular files.
File descriptor subscription_fd_readwrite::file_descriptor has capacity available for writing. This event always triggers for regular files.
Append mode: Data written to the file is always appended to the file’s end.
Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized.
Non-blocking mode.
Synchronized read I/O operations.
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.
The “standard error” descriptor number.
The “standard input” descriptor number.
The “standard output” descriptor number.
The file descriptor or file refers to a block device inode.
The file descriptor or file refers to a character device inode.
The file descriptor or file refers to a directory inode.
The file descriptor or file refers to a regular file inode.
The file descriptor or file refers to a datagram socket.
The file descriptor or file refers to a raw socket.
The file descriptor or file refers to a sequential packet socket.
The file descriptor or file refers to a byte-stream socket.
The file refers to a symbolic link inode.
The type of the file descriptor or file is unknown or is different from any of the other types specified.
Adjust the last data access timestamp to the value stored in filestat::atim.
Adjust the last data access timestamp to the time of clock clockid::realtime.
Adjust the last data modification timestamp to the value stored in filestat::mtim.
Adjust the last data modification timestamp to the time of clock clockid::realtime.
As long as the resolved path corresponds to a symbolic link, it is expanded.
Create file if it does not exist.
Fail if not a directory.
Fail if file already exists.
Truncate file to size 0.
A pre-opened directory.
Indicates if the packet should be truncated to the buffer size
Returns the message without removing it from the socket’s receive queue.
On byte-stream sockets, block until the full amount of data can be returned.
The right to invoke fd_advise.
The right to invoke fd_allocate.
The right to invoke fd_datasync. If path_open is set, includes the right to invoke path_open with fdflags::dsync.
The right to invoke fd_fdstat_set_flags.
The right to invoke fd_filestat_get.
The right to invoke fd_filestat_set_size.
The right to invoke fd_filestat_set_times.
The right to invoke fd_read and sock_recv. If rights::fd_seek is set, includes the right to invoke fd_pread.
The right to invoke fd_readdir.
The right to invoke fd_seek. This flag implies rights::fd_tell.
The right to invoke fd_sync. If path_open is set, includes the right to invoke path_open with fdflags::rsync and fdflags::dsync.
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 invoke fd_tell.
The right to invoke fd_write and sock_send. If rights::fd_seek is set, includes the right to invoke fd_pwrite.
The right to invoke path_create_directory.
If path_open is set, the right to invoke path_open with oflags::creat.
The right to invoke path_filestat_get.
The right to change a file’s size (there is no path_filestat_set_size). If path_open is set, includes the right to invoke path_open with oflags::trunc.
The right to invoke path_filestat_set_times.
The right to invoke path_link with the file descriptor as the source directory.
The right to invoke path_link with the file descriptor as the target directory.
The right to invoke path_open.
The right to invoke path_readlink.
The right to invoke path_remove_directory.
The right to invoke path_rename with the file descriptor as the source directory.
The right to invoke path_rename with the file descriptor as the target directory.
The right to invoke path_symlink.
The right to invoke path_unlink_file.
If rights::fd_read is set, includes the right to invoke poll_oneoff to subscribe to eventtype::fd_read. If rights::fd_write is set, includes the right to invoke poll_oneoff to subscribe to eventtype::fd_write.
Accept incoming connection
Retrieve locally bound address on a socket
Retrieve remote address on a socket
Bind an address to a socket
Connect to an address
Listen for incoming connection on an address
Receive data on a socket
Receive datagram on a socket
Send data on a socket
Send datagram on a socket
The right to invoke sock_shutdown.
Returned by sock_recv: Message data has been truncated.
Disables further receive operations.
Disables further send operations.
Process abort signal. Action: Terminates the process.
Alarm clock. Action: Terminates the process.
Access to an undefined portion of a memory object. Action: Terminates the process.
Child process terminated, stopped, or continued. Action: Ignored.
Continue executing, if stopped. Action: Continues executing, if stopped.
Erroneous arithmetic operation. Action: Terminates the process.
Hangup. Action: Terminates the process.
Illegal instruction. Action: Terminates the process.
Terminate interrupt signal. Action: Terminates the process.
Kill. Action: Terminates the process.
No signal. Note that POSIX has special semantics for kill(pid, 0), so this value is reserved.
Write on a pipe with no one to read it. Action: Ignored.
I/O possible. Action: Terminates the process.
Profiling timer expired. Action: Terminates the process.
Power failure. Action: Terminates the process.
Terminal quit signal. Action: Terminates the process.
Invalid memory reference. Action: Terminates the process.
Stop executing. Action: Stops executing.
Bad system call. Action: Terminates the process.
Termination signal. Action: Terminates the process.
Trace/breakpoint trap. Action: Terminates the process.
Terminal stop signal. Action: Stops executing.
Background process attempting read. Action: Stops executing.
Background process attempting write. Action: Stops executing.
High bandwidth data is available at a socket. Action: Ignored.
User-defined signal 1. Action: Terminates the process.
User-defined signal 2. Action: Terminates the process.
Virtual timer expired. Action: Terminates the process.
Window changed. Action: Ignored.
CPU time limit exceeded. Action: Terminates the process.
File size limit exceeded. Action: Terminates the process.
Socket is listening
Multicast TTL for IPv4
Socket option that does nothing
Only accept IPv6
Out-of-band inline
Protocol of the socket
Receive buffer size
TTL of packets
Type of socket
The socket has closed
The socket has failed
The socket has fully opened
The socket is still opening
The file descriptor or file refers to a datagram socket.
The file descriptor or file refers to a raw socket.
The file descriptor or file refers to a sequential packet socket.
The file descriptor or file refers to a byte-stream socket.
The stdio will inherit from its parent
The stdio will be written to the log file
The stdio will be dumped to null
The stdio will be piped
If set, treat the timestamp provided in subscription_clock::timeout as an absolute timestamp of clock subscription_clock::id. If clear, treat the timestamp provided in subscription_clock::timeout relative to the current time value of clock subscription_clock::id.
Seek relative to current position.
Seek relative to end-of-file.
Seek relative to start-of-file.

Functions

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.
Return command-line argument data sizes.
Invokes a call within a running bus process.
Closes a bus process and releases all associated resources
Spawns a new bus process for a particular web WebAssembly binary that is referenced by its process name.
Spawns a new bus process for a particular web WebAssembly binary that is referenced by its process name on a remote instance.
Polls for any outstanding events from a particular bus process by its handle
Invokes a call within the context of another call
Closes a bus call based on its bus call handle
Causes a fault on a particular call that was made to this process from another process; where ‘bid’ is the callering process context.
Replies to a call that was made to this process from another process; where ‘cid’ is the call context. This will may also drop the handle and release any associated resources (if keepalive is not set)
Registers a callback function for reactors
Registers a callback function for signals
Registers a callback function for new threads
Registers a callback function for destruction of thread locals
Sets the current working directory
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 to clock_getres in POSIX.
Return the time value of a clock. Note: This is similar to clock_gettime in POSIX.
Sets the time value of a clock. Note: This is similar to clock_settime in POSIX.
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 \0s.
Return environment variable data sizes.
Provide file advisory information on a file descriptor. Note: This is similar to posix_fadvise in POSIX.
Force the allocation of space in a file. Note: This is similar to posix_fallocate in POSIX.
Close a file descriptor. Note: This is similar to close in POSIX.
Synchronize the data of a file to disk. Note: This is similar to fdatasync in POSIX.
Atomically duplicate a file handle.
Creates a file handle for event notifications
Get the attributes of a file descriptor. Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX, as well as additional fields.
Adjust the flags associated with a file descriptor. Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.
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
Return the attributes of an open file.
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.
Adjust the timestamps of an open file or directory. Note: This is similar to futimens in POSIX.
Opens a pipe with two file handles
Read from a file descriptor, without using and updating the file descriptor’s offset. Note: This is similar to preadv in POSIX.
Return a description of the given preopened file descriptor.
Return a description of the given preopened file descriptor.
Write to a file descriptor, without using and updating the file descriptor’s offset. Note: This is similar to pwritev in POSIX.
Read from a file descriptor. Note: This is similar to readv in POSIX.
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 by dirent::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.
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 if dup2() were to be removed entirely.
Move the offset of a file descriptor. Note: This is similar to lseek in POSIX.
Synchronize the data and metadata of a file to disk. Note: This is similar to fsync in POSIX.
Return the current offset of a file descriptor. Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.
Write to a file descriptor. Note: This is similar to writev in POSIX.
Wait for a futex_wake operation to wake us. Returns with EINVAL if the futex doesn’t hold the expected value. Returns false on timeout, and true in all other cases.
Wake up one thread that’s blocked on futex_wait on this futex. Returns true if this actually woke up such a thread, or false if no thread was waiting on this futex.
Wake up all threads that are waiting on futex_wait on this futex.
Returns the current working directory If the path exceeds the size of the buffer then this function will fill the path_len with the needed size and return EOVERFLOW
Makes a HTTP request to a remote web resource and returns a socket handles that are used to send and receive data
Retrieves the status of a HTTP request
Create a directory. Note: This is similar to mkdirat in POSIX.
Return the attributes of a file or directory. Note: This is similar to stat in POSIX.
Adjust the timestamps of a file or directory. Note: This is similar to utimensat in POSIX.
Create a hard link. Note: This is similar to linkat in POSIX.
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.
Read the contents of a symbolic link. Note: This is similar to readlinkat in POSIX.
Remove a directory. Return errno::notempty if the directory is not empty. Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.
Rename a file or directory. Note: This is similar to renameat in POSIX.
Create a symbolic link. Note: This is similar to symlinkat in POSIX.
Unlink a file. Return errno::isdir if the path refers to a directory. Note: This is similar to unlinkat(fd, path, 0) in POSIX.
Concurrently poll for the occurrence of a set of events.
Adds another static address to the local port
Clears all the addresses on the local port
Returns a list of all the addresses owned by the local port This function fills the output buffer as much as possible. If the buffer is not big enough then the naddrs address will be filled with the buffer size needed and the EOVERFLOW will be returned
Removes an address from the local port
Securely connects to a particular remote network
Acquires a set of addresses using DHCP
Adds a default gateway to the port
Returns the MAC address of the local port
Adds a new route to the local port
Clears all the routes in the local port
Returns a list of all the routes owned by the local port This function fills the output buffer as much as possible. If the buffer is too small this will return EOVERFLOW and fill nroutes with the size of the buffer needed.
Removes an existing route from the local port
Disconnects from a remote network
execve() executes the program referred to by pathname. This causes the program that is currently being run by the calling process to be replaced with a new program, with newly initialized stack, heap, and (initialized and uninitialized) data segments
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.
Forks the current process into a new subprocess. If the function returns a zero then its the new subprocess. If it returns a positive number then its the current process and the $pid represents the child.
Returns the handle of the current process
Wait for process to exit
Returns the parent handle of a particular process
Send a signal to the process of the calling thread. Note: This is similar to raise in POSIX.
Sends a signal to a process
Spawns a new process within the context of this machine
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.
Resolves a hostname and a port to one or more IP addresses.
Temporarily yield execution of the calling thread. Note: This is similar to sched_yield in POSIX.
Accept a new incoming connection. Note: This is similar to accept in POSIX.
Returns the local address to which the socket is bound.
Returns the remote address to which the socket is connected to.
Bind a socket Note: This is similar to bind in POSIX using PF_INET
Initiate a connection on a socket to the specified address
Retrieve status of particular socket seting Note: This is similar to getsockopt in POSIX for SO_REUSEADDR
Retrieve the size of particular option for this socket Note: This is similar to getsockopt in POSIX for SO_RCVBUF
Retrieve one of the times on the socket
Joins a particular multicast IPv4 group
Joins a particular multicast IPv6 group
Leaves a particular multicast IPv4 group
Leaves a particular multicast IPv6 group
Listen for connections on a socket
Create an endpoint for communication.
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 of readv.
Receive a message and its peer address from a socket. Note: This is similar to recvfrom in POSIX, though it also supports reading the data into multiple buffers in the manner of readv.
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 of writev.
Sends the entire contents of a file down a socket
Send a message on a socket to a specific address. Note: This is similar to sendto in POSIX, though it also supports writing the data from multiple buffers in the manner of writev.
Sets a particular socket setting Note: This is similar to setsockopt in POSIX for SO_REUSEADDR
Set size of particular option for this socket Note: This is similar to setsockopt in POSIX for SO_RCVBUF
Sets one of the times the socket
Shut down socket send and receive channels. Note: This is similar to shutdown in POSIX.
Returns the current status of a socket
Creates a checkpoint of the current stack which allows it to be restored later using its stack hash. The value supplied will be returned upon restoration (and hence must be none zero) - zero will be returned when the stack is first recorded. This function will read the __stack_pointer global
Restores the current stack to a previous stack described by a supplied stack snapshot. This function will manipulate the __stack_pointer global
Terminates the current running thread, if this is the last thread then the process will also exit with the specified exit code. An exit code of 0 indicates successful termination of the thread. The meanings of other values is dependent on the environment.
Returns the index of the current thread (threads indices are sequencial from zero)
Joins this thread with another thread, blocking this one until the other finishes
Create a thread local variable If The web assembly process exports function named ‘_thread_local_destroy’ then it will be invoked when the thread goes out of scope and dies.
Destroys a thread local variable
Gets the value of a thread local variable
Sets the value of a thread local variable
Returns the available parallelism which is normally the number of available cores that can run concurrently
Sends a signal to a thread
Sends the current thread to sleep for a period of time
Creates a new thread by spawning that shares the same memory address space, file handles and main event loops. The web assembly process must export function named ‘_start_thread’
Retrieves the current state of the TTY
Updates the properties of the rect
Connects to a websocket at a particular network URL

Type Definitions

Unions