wasmedge_sys

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

impl Executor

Source

pub fn call_func( &mut self, func: &mut 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: &mut 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( &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.

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( &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.

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<FuncRef: AsFunc>( &mut self, func_ref: &mut 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<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.

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

Source

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

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

Source

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.

Source

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.

Trait Implementations§

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

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.