pub trait Environment<EntryPoint = DispatchKind>: Sizedwhere
    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.

Implementors§