pub trait WasiView: IoView {
// Required method
fn ctx(&mut self) -> &mut WasiCtx;
}
Expand description
A trait which provides access to the WasiCtx
inside the embedder’s T
of Store<T>
.
This crate’s WASI Host implementations depend on the contents of
WasiCtx
. The T
type Store<T>
is defined in each
embedding of Wasmtime. These implementations are connected to the
Linker<T>
by the
add_to_linker_sync
and
add_to_linker_async
functions.
The WasiView
trait implies the IoView
trait, so each T
must
also contain a ResourceTable
and impl IoView
.
§Example
use wasmtime_wasi::{WasiCtx, ResourceTable, WasiView, IoView, WasiCtxBuilder};
struct MyState {
ctx: WasiCtx,
table: ResourceTable,
}
impl IoView for MyState {
fn table(&mut self) -> &mut ResourceTable { &mut self.table }
}
impl WasiView for MyState {
fn ctx(&mut self) -> &mut WasiCtx { &mut self.ctx }
}