pub struct Executor { /* private fields */ }
Expand description
Defines an execution environment for both pure WASM and compiled WASM.
Implementations§
Source§impl Executor
impl Executor
Sourcepub fn create(
config: Option<&Config>,
stat: Option<Statistics>,
) -> WasmEdgeResult<Self>
pub fn create( config: Option<&Config>, stat: Option<Statistics>, ) -> WasmEdgeResult<Self>
Creates a new executor to be associated with the given config and statistics.
§Arguments
-
config
- The configuration of the new executor. -
stat
- The statistics needed by the new executor.
§Error
If fail to create a executor, then an error is returned.
Source§impl Executor
impl Executor
Sourcepub fn call_func(
&mut self,
func: &mut Function,
params: impl IntoIterator<Item = WasmValue>,
) -> WasmEdgeResult<Vec<WasmValue>>
pub fn call_func( &mut self, func: &mut Function, params: impl IntoIterator<Item = WasmValue>, ) -> WasmEdgeResult<Vec<WasmValue>>
Sourcepub fn call_func_with_timeout(
&self,
func: &mut Function,
params: impl IntoIterator<Item = WasmValue>,
timeout: Duration,
) -> WasmEdgeResult<Vec<WasmValue>>
Available on Linux and non-musl only.
pub fn call_func_with_timeout( &self, func: &mut Function, params: impl IntoIterator<Item = WasmValue>, timeout: Duration, ) -> WasmEdgeResult<Vec<WasmValue>>
Sourcepub async fn call_func_async(
&mut self,
async_state: &AsyncState,
func: &mut Function,
params: impl IntoIterator<Item = WasmValue> + Send,
) -> WasmEdgeResult<Vec<WasmValue>>
Available on crate feature async
and Linux only.
pub async fn call_func_async( &mut self, async_state: &AsyncState, func: &mut Function, params: impl IntoIterator<Item = WasmValue> + Send, ) -> WasmEdgeResult<Vec<WasmValue>>
async
and Linux only.Sourcepub async fn call_func_async_with_timeout(
&mut self,
async_state: &AsyncState,
func: &mut Function,
params: impl IntoIterator<Item = WasmValue> + Send,
timeout: Duration,
) -> WasmEdgeResult<Vec<WasmValue>>
Available on crate feature async
and Linux and non-musl only.
pub async fn call_func_async_with_timeout( &mut self, async_state: &AsyncState, func: &mut Function, params: impl IntoIterator<Item = WasmValue> + Send, timeout: Duration, ) -> WasmEdgeResult<Vec<WasmValue>>
async
and Linux and non-musl only.Asynchronously runs a host function instance with a timeout setting
§Arguments
-
async_state
- Used to store asynchronous state at run time. -
func
- The function instance to run. -
params
- The arguments to pass to the function. -
timeout
- The maximum execution time of the function to be run.
§Errors
If fail to run the host function, then an error is returned.
Sourcepub fn call_func_ref<FuncRef: AsFunc>(
&mut self,
func_ref: &mut FuncRef,
params: impl IntoIterator<Item = WasmValue>,
) -> WasmEdgeResult<Vec<WasmValue>>
pub fn call_func_ref<FuncRef: AsFunc>( &mut self, func_ref: &mut FuncRef, params: impl IntoIterator<Item = WasmValue>, ) -> WasmEdgeResult<Vec<WasmValue>>
Sourcepub async fn call_func_ref_async<FuncRef: AsFunc + Send>(
&mut self,
async_state: &AsyncState,
func_ref: &mut FuncRef,
params: impl IntoIterator<Item = WasmValue> + Send,
) -> WasmEdgeResult<Vec<WasmValue>>
Available on crate feature async
and Linux only.
pub async fn call_func_ref_async<FuncRef: AsFunc + Send>( &mut self, async_state: &AsyncState, func_ref: &mut FuncRef, params: impl IntoIterator<Item = WasmValue> + Send, ) -> WasmEdgeResult<Vec<WasmValue>>
async
and Linux only.Asynchronously runs a host function reference instance and returns the results.
§Arguments
-
async_state
- Used to store asynchronous state at run time. -
func_ref
- The function reference instance to run. -
params
- The arguments to pass to the function.
§Errors
If fail to run the host function reference instance, then an error is returned.
Source§impl Executor
impl Executor
Sourcepub fn register_import_module<T: AsInstance + ?Sized>(
&mut self,
store: &mut Store,
import: &T,
) -> WasmEdgeResult<()>
pub fn register_import_module<T: AsInstance + ?Sized>( &mut self, store: &mut Store, import: &T, ) -> WasmEdgeResult<()>
Registers and instantiates a import module into a store.
§Arguments
-
store
- The target store, into which the given import module is registered. -
import
- The WasmEdge import module to be registered.
§Error
If fail to register the given import module, then an error is returned.
Sourcepub fn register_named_module(
&mut self,
store: &mut Store,
module: &Module,
name: impl AsRef<str>,
) -> WasmEdgeResult<Instance>
pub fn register_named_module( &mut self, store: &mut Store, module: &Module, name: impl AsRef<str>, ) -> WasmEdgeResult<Instance>
Registers and instantiates a WasmEdge module into a store.
Instantiates the given WasmEdge module, including the functions, memories, tables, and globals it hosts; and then, registers the module instance into the store with the given name.
§Arguments
-
store
- The target store, into which the given module is registered. -
module
- A validated module to be registered. -
name
- The exported name of the registered module.
§Error
If fail to register the given module, then an error is returned.
Sourcepub fn register_active_module(
&mut self,
store: &mut Store,
module: &Module,
) -> WasmEdgeResult<Instance>
pub fn register_active_module( &mut self, store: &mut Store, module: &Module, ) -> WasmEdgeResult<Instance>
Registers and instantiates a WasmEdge module into a store as an anonymous module.
Notice that when a new module is instantiated into the store, the old instantiated module is removed; in addition, ensure that the imports the module depends on are already registered into the store.
§Arguments
-
store
- The store, in which the module to be instantiated is stored. -
ast_mod
- The target module to be instantiated.
§Error
If fail to instantiate the given module, then an error is returned.