wasmtime_wasi

Trait IoView

Source
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§

Source

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.

Implementations on Foreign Types§

Source§

impl<T> IoView for &mut T
where T: IoView + ?Sized,

Source§

fn table(&mut self) -> &mut ResourceTable

Source§

impl<T> IoView for Box<T>
where T: IoView + ?Sized,

Source§

fn table(&mut self) -> &mut ResourceTable

Implementors§

Source§

impl IoView for WasiP1Ctx

Available on crate feature preview1 only.
Source§

impl<T> IoView for IoImpl<T>
where T: IoView,

Source§

impl<T: IoView> IoView for WasiImpl<T>