pub struct PluginModuleBuilder<T: ?Sized + Send + Sync + Clone> { /* private fields */ }
Expand description

Implementations§

source§

impl<T: ?Sized + Send + Sync + Clone> PluginModuleBuilder<T>

source

pub fn new() -> Self

Creates a new PluginModuleBuilder.

source

pub fn with_func<Args, Rets, D>( self, name: impl AsRef<str>, real_func: impl Fn(CallingFrame, Vec<WasmValue>, *mut c_void) -> Result<Vec<WasmValue>, HostFuncError> + Send + Sync + 'static, data: Option<Box<D>> ) -> WasmEdgeResult<Self>where Args: WasmValTypeList, Rets: WasmValTypeList,

Adds a host function to the crate::ImportObject to create.

N.B. that this function can be used in thread-safe scenarios.

Arguments
  • name - The exported name of the host function to add.

  • real_func - The native function.

  • data - The additional data object to set to this host function context.

error

If fail to create or add the host function, then an error is returned.

source

pub fn with_async_func<Args, Rets, D>( self, name: impl AsRef<str>, real_func: impl Fn(CallingFrame, Vec<WasmValue>, *mut c_void) -> Box<dyn Future<Output = Result<Vec<WasmValue>, HostFuncError>> + Send> + Send + Sync + 'static, data: Option<Box<D>> ) -> WasmEdgeResult<Self>where Args: WasmValTypeList, Rets: WasmValTypeList, D: Send + Sync,

Available on crate feature async and Linux only.

Adds an async host function to the PluginModule to create.

N.B. that this function can be used in thread-safe scenarios.

Arguments
  • name - The exported name of the host function to add.

  • real_func - The native function.

error

If fail to create or add the host function, then an error is returned.

source

pub fn with_global(self, name: impl AsRef<str>, global: Global) -> Self

Adds a global to the PluginModule to create.

Arguments
source

pub fn with_memory(self, name: impl AsRef<str>, memory: Memory) -> Self

Adds a memory to the PluginModule to create.

Arguments
source

pub fn with_table(self, name: impl AsRef<str>, table: Table) -> Self

Adds a table to the PluginModule to create.

Arguments
source

pub fn with_host_data(self, host_data: Box<T>) -> Self

Adds host data to the PluginModule to create.

Arguments
  • host_data - The host data to be stored in the module instance.

  • finalizer - The function to drop the host data. Notice that this argument is available only if host_data is set some value.

source

pub fn build(self, name: impl AsRef<str>) -> WasmEdgeResult<PluginModule>

Creates a new PluginModule.

Argument
Error

If fail to create the PluginModule, then an error is returned.

Trait Implementations§

source§

impl<T: Debug + ?Sized + Send + Sync + Clone> Debug for PluginModuleBuilder<T>

source§

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

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

impl<T: Default + ?Sized + Send + Sync + Clone> Default for PluginModuleBuilder<T>

source§

fn default() -> PluginModuleBuilder<T>

Returns the “default value” for a type. 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, 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