Skip to main content

WasiView

Trait WasiView 

Source
pub trait WasiView: Send {
    // Required method
    fn ctx(&mut self) -> WasiCtxView<'_>;
}
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 add_to_linker_async functions.

§Example

use wasmtime_wasi::{WasiCtx, WasiCtxView, WasiView};
use wasmtime::component::ResourceTable;

struct MyState {
    ctx: WasiCtx,
    table: ResourceTable,
}

impl WasiView for MyState {
    fn ctx(&mut self) -> WasiCtxView<'_> {
        WasiCtxView{
            ctx: &mut self.ctx,
            table: &mut self.table,
        }
    }
}

Required Methods§

Source

fn ctx(&mut self) -> WasiCtxView<'_>

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

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl WasiView for WasiP1Ctx

Available on crate feature p1 only.