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>
fn execute<PrepareMemory, PrepareMemoryError>( self, prepare_memory: PrepareMemory, ) -> EnvironmentExecutionResult<PrepareMemoryError, Self, EntryPoint>
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.