wasmtime_wasi

Trait WasiView

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

Required Methods§

Source

fn ctx(&mut self) -> &mut WasiCtx

Yields mutable access to the WasiCtx configuration used for this context.

Implementations on Foreign Types§

Source§

impl<T: ?Sized + WasiView> WasiView for &mut T

Source§

fn ctx(&mut self) -> &mut WasiCtx

Source§

impl<T: ?Sized + WasiView> WasiView for Box<T>

Source§

fn ctx(&mut self) -> &mut WasiCtx

Implementors§

Source§

impl WasiView for WasiP1Ctx

Available on crate feature preview1 only.
Source§

impl<T: WasiView> WasiView for WasiImpl<T>