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

source

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
Error

If fail to create a executor, then an error is returned.

source

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.

source

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
Error

If fail to register the given import module, then an error is returned.

source

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.

source

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.

source

pub fn register_plugin_instance( &mut self, store: &Store, instance: &Instance ) -> WasmEdgeResult<()>

Registers plugin module instance into a store.

Arguments
  • store - The store, in which the module to be instantiated is stored.

  • instance - The plugin module instance to be registered.

Error

If fail to register the given plugin module instance, then an error is returned.

source

pub fn call_func( &self, func: &Function, params: impl IntoIterator<Item = WasmValue> ) -> WasmEdgeResult<Vec<WasmValue>>

Runs a host function instance and returns the results.

Arguments
  • func - The function instance to run.

  • params - The arguments to pass to the function.

Errors

If fail to run the host function, then an error is returned.

source

pub 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.

Run a host function instance and return the results or timeout.

Arguments
  • 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.

source

pub 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.

Asynchronously runs a host function instance and returns the results.

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.

Errors

If fail to run the host function, then an error is returned.

source

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>>

Available on crate feature 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.

source

pub fn call_func_ref( &self, func_ref: &FuncRef, params: impl IntoIterator<Item = WasmValue> ) -> WasmEdgeResult<Vec<WasmValue>>

Runs a host function reference instance and returns the results.

Arguments
  • 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

pub 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.

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

pub fn as_ptr(&self) -> *const WasmEdge_ExecutorContext

Available on crate feature ffi only.

Provides a raw pointer to the inner Executor context.

Trait Implementations§

source§

impl Clone for Executor

source§

fn clone(&self) -> Executor

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Executor

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Executor

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Engine for Executor

source§

fn run_func( &self, func: &Function, params: impl IntoIterator<Item = WasmValue> ) -> WasmEdgeResult<Vec<WasmValue>>

Runs a host function instance and returns the results. Read more
source§

fn run_func_ref( &self, func_ref: &FuncRef, params: impl IntoIterator<Item = WasmValue> ) -> WasmEdgeResult<Vec<WasmValue>>

Runs a host function instance by calling its reference and returns the results. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V