Trait gear_backend_common::Environment
source · 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§
type Ext: BackendExternalities + 'static
sourcetype SystemError: Debug + Display
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§
sourcefn new(
ext: Self::Ext,
binary: &[u8],
entry_point: EntryPoint,
entries: BTreeSet<DispatchKind>,
mem_size: WasmPage
) -> Result<Self, EnvironmentError<Self::SystemError, Infallible>>
fn new( ext: Self::Ext, binary: &[u8], entry_point: EntryPoint, entries: BTreeSet<DispatchKind>, mem_size: WasmPage ) -> Result<Self, EnvironmentError<Self::SystemError, Infallible>>
- Instantiates wasm binary.
- Creates wasm memory
- Runs
prepare_memory
to fill the memory before running instance. - Instantiate external funcs for wasm module.
sourcefn execute<PrepareMemory, PrepareMemoryError>(
self,
prepare_memory: PrepareMemory
) -> EnvironmentExecutionResult<PrepareMemoryError, Self, EntryPoint>where
PrepareMemory: FnOnce(&mut Self::Memory, Option<u32>, GlobalsAccessConfig) -> Result<(), PrepareMemoryError>,
PrepareMemoryError: Display,
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.