Struct wasmedge_sdk::ImportObjectBuilder

source ·
pub struct ImportObjectBuilder<Data> { /* private fields */ }
Expand description

Creates a import object.

Implementations§

source§

impl<Data> ImportObjectBuilder<Data>

source

pub fn new(name: &str, data: Data) -> WasmEdgeResult<Self>

Creates a new ImportObjectBuilder.

source

pub fn with_func<Args, Rets>( &mut self, name: impl AsRef<str>, real_func: SyncFn<Data> ) -> WasmEdgeResult<&mut Self>
where Args: WasmValTypeList, Rets: WasmValTypeList,

Adds a host function to the 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 host context data used in this function.

§error

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

source

pub fn with_func_by_type( &mut self, name: impl AsRef<str>, ty: FuncType, real_func: SyncFn<Data> ) -> WasmEdgeResult<&mut Self>

Adds a host function to the 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.

  • ty - The function type.

  • real_func - The native function.

  • data - The host context data used in this 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 ImportObject to create.

§Arguments
source

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

Adds a memory to the ImportObject to create.

§Arguments
source

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

Adds a table to the ImportObject to create.

§Arguments
source

pub fn build(self) -> ImportObject<Data>

Creates a new ImportObject.

§Argument
  • name - The name of the ImportObject to create.

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

§Error

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

Trait Implementations§

source§

impl<Data: Debug> Debug for ImportObjectBuilder<Data>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Data> Freeze for ImportObjectBuilder<Data>

§

impl<Data> RefUnwindSafe for ImportObjectBuilder<Data>
where Data: RefUnwindSafe,

§

impl<Data> Send for ImportObjectBuilder<Data>
where Data: Send,

§

impl<Data> Sync for ImportObjectBuilder<Data>
where Data: Sync,

§

impl<Data> Unpin for ImportObjectBuilder<Data>
where Data: Unpin,

§

impl<Data> UnwindSafe for ImportObjectBuilder<Data>
where Data: UnwindSafe,

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

§

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

§

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.