pub struct WasiCtx(/* private fields */);
Expand description
An Arc
-wrapper around the wasi-common context to allow mutable access to
the file descriptor table. This wrapper is only necessary due to the
signature of fd_fdstat_set_flags
; if that changes, there are a variety of
improvements that can be made (TODO:
https://github.com/bytecodealliance/wasmtime/issues/5643).
Implementations§
Source§impl WasiCtx
impl WasiCtx
pub fn new( random: Box<dyn RngCore + Send + Sync>, clocks: WasiClocks, sched: Box<dyn WasiSched>, table: Table, ) -> Self
pub fn insert_file( &self, fd: u32, file: Box<dyn WasiFile>, access_mode: FileAccessMode, )
pub fn push_file( &self, file: Box<dyn WasiFile>, access_mode: FileAccessMode, ) -> Result<u32, Error>
pub fn insert_dir(&self, fd: u32, dir: Box<dyn WasiDir>, path: PathBuf)
pub fn push_dir( &self, dir: Box<dyn WasiDir>, path: PathBuf, ) -> Result<u32, Error>
pub fn table(&self) -> &Table
pub fn table_mut(&mut self) -> Option<&mut Table>
pub fn push_arg(&mut self, arg: &str) -> Result<(), StringArrayError>
pub fn push_env( &mut self, var: &str, value: &str, ) -> Result<(), StringArrayError>
pub fn set_stdin(&self, f: Box<dyn WasiFile>)
pub fn set_stdout(&self, f: Box<dyn WasiFile>)
pub fn set_stderr(&self, f: Box<dyn WasiFile>)
pub fn push_preopened_dir( &self, dir: Box<dyn WasiDir>, path: impl AsRef<Path>, ) -> Result<(), Error>
Trait Implementations§
Source§impl WasiSnapshotPreview1 for WasiCtx
impl WasiSnapshotPreview1 for WasiCtx
async fn args_get( &mut self, memory: &mut GuestMemory<'_>, argv: GuestPtr<GuestPtr<u8>>, argv_buf: GuestPtr<u8>, ) -> Result<(), Error>
async fn args_sizes_get( &mut self, _memory: &mut GuestMemory<'_>, ) -> Result<(Size, Size), Error>
async fn environ_get( &mut self, memory: &mut GuestMemory<'_>, environ: GuestPtr<GuestPtr<u8>>, environ_buf: GuestPtr<u8>, ) -> Result<(), Error>
async fn environ_sizes_get( &mut self, _memory: &mut GuestMemory<'_>, ) -> Result<(Size, Size), Error>
async fn clock_res_get( &mut self, _memory: &mut GuestMemory<'_>, id: Clockid, ) -> Result<Timestamp, Error>
async fn clock_time_get( &mut self, _memory: &mut GuestMemory<'_>, id: Clockid, precision: Timestamp, ) -> Result<Timestamp, Error>
async fn fd_advise( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, offset: Filesize, len: Filesize, advice: Advice, ) -> Result<(), Error>
async fn fd_allocate( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, _offset: Filesize, _len: Filesize, ) -> Result<(), Error>
async fn fd_close( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<(), Error>
async fn fd_datasync( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<(), Error>
async fn fd_fdstat_get( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<Fdstat, Error>
async fn fd_fdstat_set_flags( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, flags: Fdflags, ) -> Result<(), Error>
async fn fd_fdstat_set_rights( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, _fs_rights_base: Rights, _fs_rights_inheriting: Rights, ) -> Result<(), Error>
async fn fd_filestat_get( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<Filestat, Error>
async fn fd_filestat_set_size( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, size: Filesize, ) -> Result<(), Error>
async fn fd_filestat_set_times( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, atim: Timestamp, mtim: Timestamp, fst_flags: Fstflags, ) -> Result<(), Error>
async fn fd_read( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, iovs: IovecArray, ) -> Result<Size, Error>
async fn fd_pread( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, iovs: IovecArray, offset: Filesize, ) -> Result<Size, Error>
async fn fd_write( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ciovs: CiovecArray, ) -> Result<Size, Error>
async fn fd_pwrite( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ciovs: CiovecArray, offset: Filesize, ) -> Result<Size, Error>
async fn fd_prestat_get( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<Prestat, Error>
async fn fd_prestat_dir_name( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, path: GuestPtr<u8>, path_max_len: Size, ) -> Result<(), Error>
async fn fd_renumber( &mut self, _memory: &mut GuestMemory<'_>, from: Fd, to: Fd, ) -> Result<(), Error>
async fn fd_seek( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, offset: Filedelta, whence: Whence, ) -> Result<Filesize, Error>
async fn fd_sync( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<(), Error>
async fn fd_tell( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<Filesize, Error>
async fn fd_readdir( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, buf: GuestPtr<u8>, buf_len: Size, cookie: Dircookie, ) -> Result<Size, Error>
async fn path_create_directory( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_filestat_get( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, flags: Lookupflags, path: GuestPtr<str>, ) -> Result<Filestat, Error>
async fn path_filestat_set_times( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, flags: Lookupflags, path: GuestPtr<str>, atim: Timestamp, mtim: Timestamp, fst_flags: Fstflags, ) -> Result<(), Error>
async fn path_link( &mut self, memory: &mut GuestMemory<'_>, src_fd: Fd, src_flags: Lookupflags, src_path: GuestPtr<str>, target_fd: Fd, target_path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_open( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, dirflags: Lookupflags, path: GuestPtr<str>, oflags: Oflags, fs_rights_base: Rights, _fs_rights_inheriting: Rights, fdflags: Fdflags, ) -> Result<Fd, Error>
async fn path_readlink( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, path: GuestPtr<str>, buf: GuestPtr<u8>, buf_len: Size, ) -> Result<Size, Error>
async fn path_remove_directory( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_rename( &mut self, memory: &mut GuestMemory<'_>, src_fd: Fd, src_path: GuestPtr<str>, dest_fd: Fd, dest_path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_symlink( &mut self, memory: &mut GuestMemory<'_>, src_path: GuestPtr<str>, dirfd: Fd, dest_path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_unlink_file( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, path: GuestPtr<str>, ) -> Result<(), Error>
async fn poll_oneoff( &mut self, memory: &mut GuestMemory<'_>, subs: GuestPtr<Subscription>, events: GuestPtr<Event>, nsubscriptions: Size, ) -> Result<Size, Error>
async fn proc_exit( &mut self, _memory: &mut GuestMemory<'_>, status: Exitcode, ) -> Error
async fn proc_raise( &mut self, _memory: &mut GuestMemory<'_>, _sig: Signal, ) -> Result<(), Error>
async fn sched_yield( &mut self, _memory: &mut GuestMemory<'_>, ) -> Result<(), Error>
async fn random_get( &mut self, memory: &mut GuestMemory<'_>, buf: GuestPtr<u8>, buf_len: Size, ) -> Result<(), Error>
async fn sock_accept( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, flags: Fdflags, ) -> Result<Fd, Error>
async fn sock_recv( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ri_data: IovecArray, ri_flags: Riflags, ) -> Result<(Size, Roflags), Error>
async fn sock_send( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, si_data: CiovecArray, _si_flags: Siflags, ) -> Result<Size, Error>
async fn sock_shutdown( &mut self, _memory: &mut GuestMemory<'_>, fd: Fd, how: Sdflags, ) -> Result<(), Error>
Source§impl WasiUnstable for WasiCtx
impl WasiUnstable for WasiCtx
async fn args_get( &mut self, memory: &mut GuestMemory<'_>, argv: GuestPtr<GuestPtr<u8>>, argv_buf: GuestPtr<u8>, ) -> Result<(), Error>
async fn args_sizes_get( &mut self, memory: &mut GuestMemory<'_>, ) -> Result<(Size, Size), Error>
async fn environ_get( &mut self, memory: &mut GuestMemory<'_>, environ: GuestPtr<GuestPtr<u8>>, environ_buf: GuestPtr<u8>, ) -> Result<(), Error>
async fn environ_sizes_get( &mut self, memory: &mut GuestMemory<'_>, ) -> Result<(Size, Size), Error>
async fn clock_res_get( &mut self, memory: &mut GuestMemory<'_>, id: Clockid, ) -> Result<Timestamp, Error>
async fn clock_time_get( &mut self, memory: &mut GuestMemory<'_>, id: Clockid, precision: Timestamp, ) -> Result<Timestamp, Error>
async fn fd_advise( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, offset: Filesize, len: Filesize, advice: Advice, ) -> Result<(), Error>
async fn fd_allocate( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, offset: Filesize, len: Filesize, ) -> Result<(), Error>
async fn fd_close( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<(), Error>
async fn fd_datasync( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<(), Error>
async fn fd_fdstat_get( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<Fdstat, Error>
async fn fd_fdstat_set_flags( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, flags: Fdflags, ) -> Result<(), Error>
async fn fd_fdstat_set_rights( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, fs_rights_base: Rights, fs_rights_inheriting: Rights, ) -> Result<(), Error>
async fn fd_filestat_get( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<Filestat, Error>
async fn fd_filestat_set_size( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, size: Filesize, ) -> Result<(), Error>
async fn fd_filestat_set_times( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, atim: Timestamp, mtim: Timestamp, fst_flags: Fstflags, ) -> Result<(), Error>
async fn fd_read( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, iovs: IovecArray, ) -> Result<Size, Error>
async fn fd_pread( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, iovs: IovecArray, offset: Filesize, ) -> Result<Size, Error>
async fn fd_write( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ciovs: CiovecArray, ) -> Result<Size, Error>
async fn fd_pwrite( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ciovs: CiovecArray, offset: Filesize, ) -> Result<Size, Error>
async fn fd_prestat_get( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<Prestat, Error>
async fn fd_prestat_dir_name( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, path: GuestPtr<u8>, path_max_len: Size, ) -> Result<(), Error>
async fn fd_renumber( &mut self, memory: &mut GuestMemory<'_>, from: Fd, to: Fd, ) -> Result<(), Error>
async fn fd_seek( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, offset: Filedelta, whence: Whence, ) -> Result<Filesize, Error>
async fn fd_sync( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<(), Error>
async fn fd_tell( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, ) -> Result<Filesize, Error>
async fn fd_readdir( &mut self, memory: &mut GuestMemory<'_>, fd: Fd, buf: GuestPtr<u8>, buf_len: Size, cookie: Dircookie, ) -> Result<Size, Error>
async fn path_create_directory( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_filestat_get( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, flags: Lookupflags, path: GuestPtr<str>, ) -> Result<Filestat, Error>
async fn path_filestat_set_times( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, flags: Lookupflags, path: GuestPtr<str>, atim: Timestamp, mtim: Timestamp, fst_flags: Fstflags, ) -> Result<(), Error>
async fn path_link( &mut self, memory: &mut GuestMemory<'_>, src_fd: Fd, src_flags: Lookupflags, src_path: GuestPtr<str>, target_fd: Fd, target_path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_open( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, dirflags: Lookupflags, path: GuestPtr<str>, oflags: Oflags, fs_rights_base: Rights, fs_rights_inheriting: Rights, fdflags: Fdflags, ) -> Result<Fd, Error>
async fn path_readlink( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, path: GuestPtr<str>, buf: GuestPtr<u8>, buf_len: Size, ) -> Result<Size, Error>
async fn path_remove_directory( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_rename( &mut self, memory: &mut GuestMemory<'_>, src_fd: Fd, src_path: GuestPtr<str>, dest_fd: Fd, dest_path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_symlink( &mut self, memory: &mut GuestMemory<'_>, src_path: GuestPtr<str>, dirfd: Fd, dest_path: GuestPtr<str>, ) -> Result<(), Error>
async fn path_unlink_file( &mut self, memory: &mut GuestMemory<'_>, dirfd: Fd, path: GuestPtr<str>, ) -> Result<(), Error>
async fn poll_oneoff( &mut self, memory: &mut GuestMemory<'_>, subs: GuestPtr<Subscription>, events: GuestPtr<Event>, nsubscriptions: Size, ) -> Result<Size, Error>
async fn proc_exit( &mut self, memory: &mut GuestMemory<'_>, status: Exitcode, ) -> Error
async fn proc_raise( &mut self, _memory: &mut GuestMemory<'_>, _sig: Signal, ) -> Result<(), Error>
async fn sched_yield( &mut self, memory: &mut GuestMemory<'_>, ) -> Result<(), Error>
async fn random_get( &mut self, memory: &mut GuestMemory<'_>, buf: GuestPtr<u8>, buf_len: Size, ) -> Result<(), Error>
async fn sock_recv( &mut self, _memory: &mut GuestMemory<'_>, _fd: Fd, _ri_data: IovecArray, _ri_flags: Riflags, ) -> Result<(Size, Roflags), Error>
async fn sock_send( &mut self, _memory: &mut GuestMemory<'_>, _fd: Fd, _si_data: CiovecArray, _si_flags: Siflags, ) -> Result<Size, Error>
async fn sock_shutdown( &mut self, _memory: &mut GuestMemory<'_>, _fd: Fd, _how: Sdflags, ) -> Result<(), Error>
Auto Trait Implementations§
impl Freeze for WasiCtx
impl !RefUnwindSafe for WasiCtx
impl Send for WasiCtx
impl Sync for WasiCtx
impl Unpin for WasiCtx
impl !UnwindSafe for WasiCtx
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self
file descriptor.§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more