Trait Environment

Source
pub trait Environment<EntryPoint = DispatchKind>: Sized
where EntryPoint: WasmEntryPoint,
{ type Ext: BackendExternalities + 'static; type Memory: Memory; type SystemError: Debug + Display; // Required methods fn new( ext: Self::Ext, binary: &[u8], entry_point: EntryPoint, entries: BTreeSet<DispatchKind>, mem_size: WasmPage, ) -> Result<Self, EnvironmentError<Self::SystemError, Infallible>>; fn execute<PrepareMemory, PrepareMemoryError>( self, prepare_memory: PrepareMemory, ) -> EnvironmentExecutionResult<PrepareMemoryError, Self, EntryPoint> where PrepareMemory: FnOnce(&mut Self::Memory, Option<u32>, GlobalsAccessConfig) -> Result<(), PrepareMemoryError>, PrepareMemoryError: Display; }

Required Associated Types§

Source

type Ext: BackendExternalities + 'static

Source

type Memory: Memory

Memory type for current environment.

Source

type SystemError: Debug + Display

That’s an error which originally comes from the primary wasm execution environment (set by wasmi or sandbox). So it’s not the error of the Self itself, it’s a kind of wrapper over the underlying executor error.

Required Methods§

Source

fn new( ext: Self::Ext, binary: &[u8], entry_point: EntryPoint, entries: BTreeSet<DispatchKind>, mem_size: WasmPage, ) -> Result<Self, EnvironmentError<Self::SystemError, Infallible>>

  1. Instantiates wasm binary.
  2. Creates wasm memory
  3. Runs prepare_memory to fill the memory before running instance.
  4. Instantiate external funcs for wasm module.
Source

fn execute<PrepareMemory, PrepareMemoryError>( self, prepare_memory: PrepareMemory, ) -> EnvironmentExecutionResult<PrepareMemoryError, Self, EntryPoint>
where PrepareMemory: FnOnce(&mut Self::Memory, Option<u32>, GlobalsAccessConfig) -> Result<(), PrepareMemoryError>, PrepareMemoryError: Display,

Run instance setup starting at entry_point - wasm export function name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§