pub trait IoView: Send {
// Required method
fn table(&mut self) -> &mut ResourceTable;
}
Expand description
A trait which provides access to the ResourceTable
inside the
embedder’s T
of Store<T>
.
This crate’s WASI Host implementations depend on the contents of
ResourceTable
. The T
type Store<T>
is defined in each
embedding of Wasmtime. These implementations is connected to the
Linker<T>
by the
add_to_linker_async
function.
§Example
use wasmtime::{Config, Engine};
use wasmtime::component::{ResourceTable, Linker};
use wasmtime_wasi_io::{IoView, add_to_linker_async};
struct MyState {
table: ResourceTable,
}
impl IoView for MyState {
fn table(&mut self) -> &mut ResourceTable { &mut self.table }
}
let mut config = Config::new();
config.async_support(true);
let engine = Engine::new(&config).unwrap();
let mut linker: Linker<MyState> = Linker::new(&engine);
add_to_linker_async(&mut linker).unwrap();
Required Methods§
Sourcefn table(&mut self) -> &mut ResourceTable
fn table(&mut self) -> &mut ResourceTable
Yields mutable access to the internal resource management that this context contains.
Embedders can add custom resources to this table as well to give resources to wasm as well.