[][src]Trait wasihost_core::wasi_snapshot_preview1::native::NativeWasiImports

pub trait NativeWasiImports: Send + Sync + 'static {
    fn args_get(
        &self,
        ctx: &mut Ctx,
        argv: WasmSlicePtr<WasmSlicePtr<u8>>,
        argv_buf: WasmSlicePtr<u8>
    ) -> errno;
fn args_sizes_get(&self, ctx: &mut Ctx) -> (errno, size, size);
fn environ_get(
        &self,
        ctx: &mut Ctx,
        environ: WasmSlicePtr<WasmSlicePtr<u8>>,
        environ_buf: WasmSlicePtr<u8>
    ) -> errno;
fn environ_sizes_get(&self, ctx: &mut Ctx) -> (errno, size, size);
fn clock_res_get(&self, ctx: &mut Ctx, id: clockid) -> (errno, timestamp);
fn clock_time_get(
        &self,
        ctx: &mut Ctx,
        id: clockid,
        precision: timestamp
    ) -> (errno, timestamp);
fn fd_advise(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        offset: filesize,
        len: filesize,
        advice: advice
    ) -> errno;
fn fd_allocate(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        offset: filesize,
        len: filesize
    ) -> errno;
fn fd_close(&self, ctx: &mut Ctx, fd: fd) -> errno;
fn fd_datasync(&self, ctx: &mut Ctx, fd: fd) -> errno;
fn fd_fdstat_get(&self, ctx: &mut Ctx, fd: fd) -> (errno, fdstat);
fn fd_fdstat_set_flags(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        flags: fdflags
    ) -> errno;
fn fd_fdstat_set_rights(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        fs_rights_base: rights,
        fs_rights_inheriting: rights
    ) -> errno;
fn fd_filestat_get(&self, ctx: &mut Ctx, fd: fd) -> (errno, filestat);
fn fd_filestat_set_size(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        size: filesize
    ) -> errno;
fn fd_filestat_set_times(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        atim: timestamp,
        mtim: timestamp,
        fst_flags: fstflags
    ) -> errno;
fn fd_pread(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        iovs: WasmSlicePtr<iovec>,
        iovs_len: size,
        offset: filesize
    ) -> (errno, size);
fn fd_prestat_get(&self, ctx: &mut Ctx, fd: fd) -> (errno, prestat);
fn fd_prestat_dir_name(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        path: WasmSlicePtr<u8>,
        path_len: size
    ) -> errno;
fn fd_pwrite(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        iovs: WasmSlicePtr<ciovec>,
        iovs_len: size,
        offset: filesize
    ) -> (errno, size);
fn fd_read(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        iovs: WasmSlicePtr<iovec>,
        iovs_len: size
    ) -> (errno, size);
fn fd_readdir(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        buf: WasmSlicePtr<u8>,
        buf_len: size,
        cookie: dircookie
    ) -> (errno, size);
fn fd_renumber(&self, ctx: &mut Ctx, fd: fd, to: fd) -> errno;
fn fd_seek(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        offset: filedelta,
        whence: whence
    ) -> (errno, filesize);
fn fd_sync(&self, ctx: &mut Ctx, fd: fd) -> errno;
fn fd_tell(&self, ctx: &mut Ctx, fd: fd) -> (errno, filesize);
fn fd_write(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        iovs: WasmSlicePtr<ciovec>,
        iovs_len: size
    ) -> (errno, size);
fn path_create_directory(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        path: WasmSlicePtr<u8>,
        path_len: size
    ) -> errno;
fn path_filestat_get(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        flags: lookupflags,
        path: WasmSlicePtr<u8>,
        path_len: size
    ) -> (errno, filestat);
fn path_filestat_set_times(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        flags: lookupflags,
        path: WasmSlicePtr<u8>,
        path_len: size,
        atim: timestamp,
        mtim: timestamp,
        fst_flags: fstflags
    ) -> errno;
fn path_link(
        &self,
        ctx: &mut Ctx,
        old_fd: fd,
        old_flags: lookupflags,
        old_path: WasmSlicePtr<u8>,
        old_path_len: size,
        new_fd: fd,
        new_path: WasmSlicePtr<u8>,
        new_path_len: size
    ) -> errno;
fn path_open(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        dirflags: lookupflags,
        path: WasmSlicePtr<u8>,
        path_len: size,
        oflags: oflags,
        fs_rights_base: rights,
        fs_rights_inherting: rights,
        fdflags: fdflags
    ) -> (errno, fd);
fn path_readlink(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        path: WasmSlicePtr<u8>,
        path_len: size,
        buf: WasmSlicePtr<u8>,
        buf_len: size
    ) -> (errno, size);
fn path_remove_directory(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        path: WasmSlicePtr<u8>,
        path_len: size
    ) -> errno;
fn path_rename(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        old_path: WasmSlicePtr<u8>,
        old_path_len: size,
        new_fd: fd,
        new_path: WasmSlicePtr<u8>,
        new_path_len: size
    ) -> errno;
fn path_symlink(
        &self,
        ctx: &mut Ctx,
        old_path: WasmSlicePtr<u8>,
        old_path_len: size,
        fd: fd,
        new_path: WasmSlicePtr<u8>,
        new_path_len: size
    ) -> errno;
fn path_unlink_file(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        path: WasmSlicePtr<u8>,
        path_len: size
    ) -> errno;
fn poll_oneoff(
        &self,
        ctx: &mut Ctx,
        r#in: WasmSlicePtr<subscription>,
        out: WasmSlicePtr<event>,
        nsubscriptions: size
    ) -> (errno, size);
fn proc_exit(
        &self,
        ctx: &mut Ctx,
        rval: exitcode
    ) -> Result<Infallible, exitcode>;
fn proc_raise(&self, ctx: &mut Ctx, sig: signal) -> errno;
fn sched_yield(&self, ctx: &mut Ctx) -> errno;
fn random_get(
        &self,
        ctx: &mut Ctx,
        buf: WasmSlicePtr<u8>,
        buf_len: size
    ) -> errno;
fn sock_recv(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        ri_data: WasmSlicePtr<iovec>,
        ri_data_len: size,
        ri_flags: riflags
    ) -> (errno, size, roflags);
fn sock_send(
        &self,
        ctx: &mut Ctx,
        fd: fd,
        si_data: WasmSlicePtr<ciovec>,
        si_data_len: size,
        si_flags: siflags
    ) -> (errno, size);
fn sock_shutdown(&self, ctx: &mut Ctx, fd: fd, how: sdflags) -> errno; }

Functions necessary to satisfy the WASI specification.

Required methods

fn args_get(
    &self,
    ctx: &mut Ctx,
    argv: WasmSlicePtr<WasmSlicePtr<u8>>,
    argv_buf: WasmSlicePtr<u8>
) -> errno

Read command-line argument data. The size of the array should match that returned by args_sizes_get

Parameters

  • ctx: The WASM runtime context
  • argv:
  • argv_buf:

Results

fn args_sizes_get(&self, ctx: &mut Ctx) -> (errno, size, size)

Return command-line argument data sizes.

Parameters

  • ctx: The WASM runtime context

Results

  • The number of arguments.
  • The size of the argument string data.

fn environ_get(
    &self,
    ctx: &mut Ctx,
    environ: WasmSlicePtr<WasmSlicePtr<u8>>,
    environ_buf: WasmSlicePtr<u8>
) -> errno

Read environment variable data. The sizes of the buffers should match that returned by environ_sizes_get.

Parameters

  • ctx: The WASM runtime context
  • environ:
  • environ_buf:

Results

fn environ_sizes_get(&self, ctx: &mut Ctx) -> (errno, size, size)

Return environment variable data sizes.

Parameters

  • ctx: The WASM runtime context

Results

  • The number of environment variable arguments.
  • The size of the environment variable data.

fn clock_res_get(&self, ctx: &mut Ctx, id: clockid) -> (errno, timestamp)

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.

Parameters

  • ctx: The WASM runtime context
  • id: The clock for which to return the resolution.

Results

  • The resolution of the clock.

fn clock_time_get(
    &self,
    ctx: &mut Ctx,
    id: clockid,
    precision: timestamp
) -> (errno, timestamp)

Return the time value of a clock. Note: This is similar to clock_gettime in POSIX.

Parameters

  • ctx: The WASM runtime context
  • id: The clock for which to return the time.
  • precision: The maximum lag (exclusive) that the returned time value may have, compared to its actual value.

Results

  • The time value of the clock.

fn fd_advise(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    offset: filesize,
    len: filesize,
    advice: advice
) -> errno

Provide file advisory information on a file descriptor. Note: This is similar to posix_fadvise in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • offset: The offset within the file to which the advisory applies.
  • len: The length of the region to which the advisory applies.
  • advice: The advice.

Results

fn fd_allocate(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    offset: filesize,
    len: filesize
) -> errno

Force the allocation of space in a file. Note: This is similar to posix_fallocate in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • offset: The offset at which to start the allocation.
  • len: The length of the area that is allocated.

Results

fn fd_close(&self, ctx: &mut Ctx, fd: fd) -> errno

Close a file descriptor. Note: This is similar to close in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:

Results

fn fd_datasync(&self, ctx: &mut Ctx, fd: fd) -> errno

Synchronize the data of a file to disk. Note: This is similar to fdatasync in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:

Results

fn fd_fdstat_get(&self, ctx: &mut Ctx, fd: fd) -> (errno, fdstat)

Get the attributes of a file descriptor. Note: This returns similar flags to fsync(fd, F_GETFL) in POSIX, as well as additional fields.

Parameters

  • ctx: The WASM runtime context
  • fd:

Results

  • The buffer where the file descriptor's attributes are stored.

fn fd_fdstat_set_flags(&self, ctx: &mut Ctx, fd: fd, flags: fdflags) -> errno

Adjust the flags associated with a file descriptor. Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • flags: The desired values of the file descriptor flags.

Results

fn fd_fdstat_set_rights(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    fs_rights_base: rights,
    fs_rights_inheriting: rights
) -> errno

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

Parameters

  • ctx: The WASM runtime context
  • fd:
  • fs_rights_base: The desired rights of the file descriptor.
  • fs_rights_inheriting:

Results

fn fd_filestat_get(&self, ctx: &mut Ctx, fd: fd) -> (errno, filestat)

Return the attributes of an open file.

Parameters

  • ctx: The WASM runtime context
  • fd:

Results

  • The buffer where the file's attributes are stored.

fn fd_filestat_set_size(&self, ctx: &mut Ctx, fd: fd, size: filesize) -> errno

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.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • size: The desired file size.

Results

fn fd_filestat_set_times(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    atim: timestamp,
    mtim: timestamp,
    fst_flags: fstflags
) -> errno

Adjust the timestamps of an open file or directory. Note: This is similar to futimens in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • atim: The desired values of the data access timestamp.
  • mtim: The desired values of the data modification timestamp.
  • fst_flags: A bitmask indicating which timestamps to adjust.

Results

fn fd_pread(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    iovs: WasmSlicePtr<iovec>,
    iovs_len: size,
    offset: filesize
) -> (errno, size)

Read from a file descriptor, without using and updating the file descriptor's offset. Note: This is similar to preadv in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • iovs: List of scatter/gather vectors in which to store data.
  • offset: The offset within the file at which to read.

Results

  • The number of bytes read.

fn fd_prestat_get(&self, ctx: &mut Ctx, fd: fd) -> (errno, prestat)

Return a description of the given preopened file descriptor.

Parameters

  • ctx: The WASM runtime context
  • fd:

Results

  • The buffer where the description is stored.

fn fd_prestat_dir_name(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    path: WasmSlicePtr<u8>,
    path_len: size
) -> errno

Return a description of the given preopened file descriptor.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • path: A buffer into which to write the preopened directory name.
  • path_len:

Results

fn fd_pwrite(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    iovs: WasmSlicePtr<ciovec>,
    iovs_len: size,
    offset: filesize
) -> (errno, size)

Write to a file descriptor, without using and updating the file descriptor's offset. Note: This is similar to pwritev in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • iovs: List of scatter/gather vectors from which to retrieve data.
  • offset: The offset within the file at which to write.

Results

  • The number of bytes written.

fn fd_read(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    iovs: WasmSlicePtr<iovec>,
    iovs_len: size
) -> (errno, size)

Read from a file descriptor. Note: This is similar to readv in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • iovs: List of scatter/gather vectors to which to store data.

Results

  • The number of bytes read.

fn fd_readdir(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    buf: WasmSlicePtr<u8>,
    buf_len: size,
    cookie: dircookie
) -> (errno, size)

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_t object, followed by dirent_t::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.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • buf: The buffer where directory entries are stored
  • buf_len:
  • cookie: The location within the directory to start reading

Results

  • The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached.

fn fd_renumber(&self, ctx: &mut Ctx, fd: fd, to: fd) -> errno

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.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • to: The file descriptor to overwrite.

Results

fn fd_seek(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    offset: filedelta,
    whence: whence
) -> (errno, filesize)

Move the offset of a file descriptor. Note: This is similar to lseek in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • offset: The number of bytes to move.
  • whence: The base from which the offset is relative.

Results

  • The new offset of the file descriptor, relative to the start of the file.

fn fd_sync(&self, ctx: &mut Ctx, fd: fd) -> errno

Synchronize the data and metadata of a file to disk. Note: This is similar to fsync in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:

Results

fn fd_tell(&self, ctx: &mut Ctx, fd: fd) -> (errno, filesize)

Return the current offset of a file descriptor. Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:

Results

  • The current offset of the file descriptor, relative to the start of the file.

fn fd_write(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    iovs: WasmSlicePtr<ciovec>,
    iovs_len: size
) -> (errno, size)

Write to a file descriptor. Note: This is similar to writev in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • iovs: List of scatter/gather vectors from which to retrieve data.

Results

  • The number of bytes written.

fn path_create_directory(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    path: WasmSlicePtr<u8>,
    path_len: size
) -> errno

Create a directory. Note: This is similar to mkdirat in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • path: The path at which to create the directory.

Results

fn path_filestat_get(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    flags: lookupflags,
    path: WasmSlicePtr<u8>,
    path_len: size
) -> (errno, filestat)

Return the attributes of a file or directory. Note: This is similar to stat in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • flags: Flags determining the method of how the path is resolved.
  • path: The path of the file or directory to inspect.

Results

  • The buffer where the file's attributes are stored.

fn path_filestat_set_times(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    flags: lookupflags,
    path: WasmSlicePtr<u8>,
    path_len: size,
    atim: timestamp,
    mtim: timestamp,
    fst_flags: fstflags
) -> errno

Adjust the timestamps of a file or directory. Note: This is similar to utimensat in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • flags: Flags determining the method of how the path is resolved.
  • path: The path of the file or directory to operate on.
  • atim: The desired values of the data access timestamp.
  • mtim: The desired values of the data modification timestamp.
  • fst_flags: A bitmask indicating which timestamps to adjust.

Results

Create a hard link. Note: This is similar to linkat in POSIX.

Parameters

  • ctx: The WASM runtime context
  • old_fd:
  • old_flags: Flags determining the method of how the path is resolved.
  • old_path: The source path from which to link.
  • new_fd: The working directory at which the resolution of the new path starts.
  • new_path: The destination path at which to create the hard link.

Results

fn path_open(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    dirflags: lookupflags,
    path: WasmSlicePtr<u8>,
    path_len: size,
    oflags: oflags,
    fs_rights_base: rights,
    fs_rights_inherting: rights,
    fdflags: fdflags
) -> (errno, fd)

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.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • dirflags: Flags determining the method of how the path is resolved.
  • path: The relative path of the file or directory to open, relative to the path_open::fd directory.
  • oflags: The method by which to open the file.
  • fs_rights_base: The initial rights of the newly created file descriptor. The implementation is allowed to return a file descriptor with fewer rights than specified, if and only if those rights do not apply to the type of file being opened. The base rights are rights that will apply to operations using the file descriptor itself, while the inheriting rights are rights that apply to file descriptors derived from it.
  • fs_rights_inherting:
  • fdflags:

Results

  • The file descriptor of the file that has been opened.

Read the contents of a symbolic link. Note: This is similar to readlinkat in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • path: The path of the symbolic link from which to read.
  • buf: The buffer to which to write the contents of the symbolic link.
  • buf_len:

Results

  • The number of bytes placed in the buffer.

fn path_remove_directory(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    path: WasmSlicePtr<u8>,
    path_len: size
) -> errno

Remove a directory. Return errno::notempty if the directory is not empty. Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • path: The path to a directory to remove.

Results

fn path_rename(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    old_path: WasmSlicePtr<u8>,
    old_path_len: size,
    new_fd: fd,
    new_path: WasmSlicePtr<u8>,
    new_path_len: size
) -> errno

Rename a file or directory. Note: This is similar to renameat in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • old_path: The source path of the file or directory to rename.
  • new_fd: The working directory at which the resolution of the new path starts.
  • new_path: The destination path to which to rename the file or directory.

Results

Create a symbolic link. Note: This is similar to symlinkat in POSIX.

Parameters

  • ctx: The WASM runtime context
  • old_path: The contents of the symbolic link.
  • fd:
  • new_path: The destination path at which to create the symbolic link.

Results

Unlink a file. Return errno::isdir if the path refers to a directory. Note: This is similar to unlinkat(fd, path, 0) in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • path: The path to a file to unlink.

Results

fn poll_oneoff(
    &self,
    ctx: &mut Ctx,
    r#in: WasmSlicePtr<subscription>,
    out: WasmSlicePtr<event>,
    nsubscriptions: size
) -> (errno, size)

Concurrently poll for the occurrence of a set of events.

Parameters

  • ctx: The WASM runtime context
  • in: The events to which to subscribe.
  • out: The events that have occurred.
  • nsubscriptions: Both the number of subscriptions and events.

Results

  • The number of events stored.

fn proc_exit(
    &self,
    ctx: &mut Ctx,
    rval: exitcode
) -> Result<Infallible, exitcode>

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.

Parameters

  • ctx: The WASM runtime context
  • rval: The exit code returned by the process.

Results

fn proc_raise(&self, ctx: &mut Ctx, sig: signal) -> errno

Send a signal to the process of the calling thread. Note: This is similar to raise in POSIX.

Parameters

  • ctx: The WASM runtime context
  • sig: The signal condition to trigger.

Results

fn sched_yield(&self, ctx: &mut Ctx) -> errno

Temporarily yield execution of the calling thread. Note: This is similar to sched_yield in POSIX.

Parameters

  • ctx: The WASM runtime context

Results

fn random_get(
    &self,
    ctx: &mut Ctx,
    buf: WasmSlicePtr<u8>,
    buf_len: size
) -> errno

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.

Parameters

  • ctx: The WASM runtime context
  • buf: The buffer to fill with random data.
  • buf_len:

Results

fn sock_recv(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    ri_data: WasmSlicePtr<iovec>,
    ri_data_len: size,
    ri_flags: riflags
) -> (errno, size, roflags)

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.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • ri_data: List of scatter/gather vectors to which to store data.
  • ri_flags: Message flags.

Results

  • Number of bytes stored in ri_data.
  • Message flags.

fn sock_send(
    &self,
    ctx: &mut Ctx,
    fd: fd,
    si_data: WasmSlicePtr<ciovec>,
    si_data_len: size,
    si_flags: siflags
) -> (errno, size)

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.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • si_data: List of scatter/gather vectors to which to retrieve data
  • si_flags: Message flags.

Results

  • Number of bytes transmitted.

fn sock_shutdown(&self, ctx: &mut Ctx, fd: fd, how: sdflags) -> errno

Shut down socket send and receive channels. Note: This is similar to shutdown in POSIX.

Parameters

  • ctx: The WASM runtime context
  • fd:
  • how: Which channels on the socket to shut down.

Results

Loading content...

Implementations on Foreign Types

impl<T: NativeWasiImports> NativeWasiImports for Arc<T>[src]

Loading content...

Implementors

Loading content...