Struct wasmedge_sys::Executor
source · 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<&mut Statistics>
) -> WasmEdgeResult<Self>
pub fn create( config: Option<&Config>, stat: Option<&mut 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.
sourcepub fn register_wasi_instance(
&mut self,
store: &Store,
instance: &WasiInstance
) -> WasmEdgeResult<()>
pub fn register_wasi_instance( &mut self, store: &Store, instance: &WasiInstance ) -> WasmEdgeResult<()>
Registers and instantiates the given WASI instance into a store.
Arguments
-
store
- The target store, into which the given [wasi instance] is registered. -
instance
- The WASI instance to be registered.
Error
If fail to register the given WASI instance, then an error is returned.
sourcepub fn register_import_module<T>(
&mut self,
store: &Store,
import: &ImportModule<T>
) -> WasmEdgeResult<()>where
T: ?Sized + Send + Sync + Clone,
pub fn register_import_module<T>( &mut self, store: &Store, import: &ImportModule<T> ) -> WasmEdgeResult<()>where T: ?Sized + Send + Sync + Clone,
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: &Store,
module: &Module,
name: impl AsRef<str>
) -> WasmEdgeResult<Instance>
pub fn register_named_module( &mut self, store: &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: &Store,
module: &Module
) -> WasmEdgeResult<Instance>
pub fn register_active_module( &mut self, store: &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.
sourcepub fn register_plugin_instance(
&mut self,
store: &Store,
instance: &Instance
) -> WasmEdgeResult<()>
pub fn register_plugin_instance( &mut self, store: &Store, instance: &Instance ) -> WasmEdgeResult<()>
sourcepub fn call_func(
&self,
func: &Function,
params: impl IntoIterator<Item = WasmValue>
) -> WasmEdgeResult<Vec<WasmValue>>
pub fn call_func( &self, func: &Function, params: impl IntoIterator<Item = WasmValue> ) -> WasmEdgeResult<Vec<WasmValue>>
sourcepub fn call_func_with_timeout(
&self,
func: &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: &Function, params: impl IntoIterator<Item = WasmValue>, timeout: Duration ) -> WasmEdgeResult<Vec<WasmValue>>
sourcepub async fn call_func_async(
&self,
async_state: &AsyncState,
func: &Function,
params: impl IntoIterator<Item = WasmValue> + Send
) -> WasmEdgeResult<Vec<WasmValue>>
Available on crate feature async
and Linux only.
pub async fn call_func_async( &self, async_state: &AsyncState, func: &Function, params: impl IntoIterator<Item = WasmValue> + Send ) -> WasmEdgeResult<Vec<WasmValue>>
async
and Linux only.sourcepub async fn call_func_async_with_timeout(
&self,
async_state: &AsyncState,
func: &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( &self, async_state: &AsyncState, func: &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(
&self,
func_ref: &FuncRef,
params: impl IntoIterator<Item = WasmValue>
) -> WasmEdgeResult<Vec<WasmValue>>
pub fn call_func_ref( &self, func_ref: &FuncRef, params: impl IntoIterator<Item = WasmValue> ) -> WasmEdgeResult<Vec<WasmValue>>
sourcepub async fn call_func_ref_async(
&self,
async_state: &AsyncState,
func_ref: &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( &self, async_state: &AsyncState, func_ref: &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.
sourcepub fn as_ptr(&self) -> *const WasmEdge_ExecutorContext
Available on crate feature ffi
only.
pub fn as_ptr(&self) -> *const WasmEdge_ExecutorContext
ffi
only.Provides a raw pointer to the inner Executor context.