Trait WasiRuntimeImplementation

Source
pub trait WasiRuntimeImplementation: Debug + Sync {
    // Required methods
    fn bus(&self) -> &dyn VirtualBus;
    fn networking(&self) -> &dyn VirtualNetworking;
    fn thread_generate_id(&self) -> WasiThreadId;

    // Provided methods
    fn tty_get(&self) -> WasiTtyState { ... }
    fn tty_set(&self, _tty_state: WasiTtyState) { ... }
    fn thread_spawn(
        &self,
        _callback: Box<dyn FnOnce() + Send + 'static>,
    ) -> Result<(), WasiThreadError> { ... }
    fn thread_parallelism(&self) -> Result<usize, WasiThreadError> { ... }
    fn yield_now(&self, _id: WasiThreadId) -> Result<(), WasiError> { ... }
    fn getpid(&self) -> Option<u32> { ... }
}
Expand description

Represents an implementation of the WASI runtime - by default everything is unimplemented.

Required Methods§

Source

fn bus(&self) -> &dyn VirtualBus

For WASI runtimes that support it they can implement a message BUS implementation which allows runtimes to pass serialized messages between each other similar to RPC’s. BUS implementation can be implemented that communicate across runtimes thus creating a distributed computing architecture.

Source

fn networking(&self) -> &dyn VirtualNetworking

Provides access to all the networking related functions such as sockets. By default networking is not implemented.

Source

fn thread_generate_id(&self) -> WasiThreadId

Generates a new thread ID

Provided Methods§

Source

fn tty_get(&self) -> WasiTtyState

Gets the TTY state

Source

fn tty_set(&self, _tty_state: WasiTtyState)

Sets the TTY state

Source

fn thread_spawn( &self, _callback: Box<dyn FnOnce() + Send + 'static>, ) -> Result<(), WasiThreadError>

Spawns a new thread by invoking the

Source

fn thread_parallelism(&self) -> Result<usize, WasiThreadError>

Returns the amount of parallelism that is possible on this platform

Source

fn yield_now(&self, _id: WasiThreadId) -> Result<(), WasiError>

Invokes whenever a WASM thread goes idle. In some runtimes (like singlethreaded execution environments) they will need to do asynchronous work whenever the main thread goes idle and this is the place to hook for that.

Source

fn getpid(&self) -> Option<u32>

Gets the current process ID

Implementors§