pub struct WasiCtx { /* private fields */ }
Expand description
Per-Store
state which holds state necessary to implement WASI from this
crate.
This structure is created through WasiCtxBuilder
and is stored within
the T
of Store<T>
. Access to the structure is provided
through the WasiView
trait as an implementation on T
.
Note that this structure itself does not have any accessors, it’s here for
internal use within the wasmtime-wasi
crate’s implementation of
bindgen-generated traits.
§Example
use wasmtime_wasi::{ResourceTable, WasiCtx, WasiCtxView, WasiView, WasiCtxBuilder};
struct MyState {
ctx: WasiCtx,
table: ResourceTable,
}
impl WasiView for MyState {
fn ctx(&mut self) -> WasiCtxView<'_> {
WasiCtxView { ctx: &mut self.ctx, table: &mut self.table }
}
}
impl MyState {
fn new() -> MyState {
let mut wasi = WasiCtxBuilder::new();
wasi.arg("./foo.wasm");
wasi.arg("--help");
wasi.env("FOO", "bar");
MyState {
ctx: wasi.build(),
table: ResourceTable::new(),
}
}
}
Implementations§
Source§impl WasiCtx
impl WasiCtx
Sourcepub fn builder() -> WasiCtxBuilder
pub fn builder() -> WasiCtxBuilder
Convenience function for calling WasiCtxBuilder::new
.
Trait Implementations§
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
§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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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