Function sc_executor::sandbox::instantiate[][src]

pub fn instantiate<FE>(
    supervisor_externals: &mut FE,
    dispatch_thunk: <FE as SandboxCapabilities>::SupervisorFuncRef,
    wasm: &[u8],
    host_env: GuestEnvironment,
    state: u32
) -> Result<UnregisteredInstance<<FE as SandboxCapabilities>::SupervisorFuncRef>, InstantiationError> where
    FE: SandboxCapabilities
Expand description

Instantiate a guest module and return it’s index in the store.

The guest module’s code is specified in wasm. Environment that will be available to guest module is specified in raw_env_def (serialized version of EnvironmentDefinition). dispatch_thunk is used as function that handle calls from guests.

Errors

Returns Err if any of the following conditions happens:

  • raw_env_def can’t be deserialized as a EnvironmentDefinition.
  • Module in wasm is invalid or couldn’t be instantiated.