pub struct ImportObjectBuilder<Data: Send> { /* private fields */ }
Expand description
Creates a async import object.
Implementations§
Source§impl<Data: Send> ImportObjectBuilder<Data>
impl<Data: Send> ImportObjectBuilder<Data>
Sourcepub fn new(name: impl AsRef<str>, data: Data) -> WasmEdgeResult<Self>
pub fn new(name: impl AsRef<str>, data: Data) -> WasmEdgeResult<Self>
Creates a new ImportObjectBuilder.
Sourcepub fn with_func<Args, Rets>(
&mut self,
name: impl AsRef<str>,
real_func: AsyncFn<'_, '_, '_, '_, Data>,
) -> WasmEdgeResult<&mut Self>where
Args: WasmValTypeList,
Rets: WasmValTypeList,
pub fn with_func<Args, Rets>(
&mut self,
name: impl AsRef<str>,
real_func: AsyncFn<'_, '_, '_, '_, 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.
Sourcepub fn with_func_by_type(
&mut self,
name: impl AsRef<str>,
ty: FuncType,
real_func: AsyncFn<'_, '_, '_, '_, Data>,
) -> WasmEdgeResult<&mut Self>
pub fn with_func_by_type( &mut self, name: impl AsRef<str>, ty: FuncType, real_func: AsyncFn<'_, '_, '_, '_, 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.
Sourcepub fn with_global(self, name: impl AsRef<str>, global: Global) -> Self
pub fn with_global(self, name: impl AsRef<str>, global: Global) -> Self
Adds a global to the ImportObject to create.
§Arguments
-
name
- The exported name of the global to add. -
global
- The wasm global instance to add.
Sourcepub fn with_memory(self, name: impl AsRef<str>, memory: Memory) -> Self
pub fn with_memory(self, name: impl AsRef<str>, memory: Memory) -> Self
Adds a memory to the ImportObject to create.
§Arguments
-
name
- The exported name of the memory to add. -
memory
- The wasm memory instance to add.
Sourcepub fn with_table(self, name: impl AsRef<str>, table: Table) -> Self
pub fn with_table(self, name: impl AsRef<str>, table: Table) -> Self
Adds a table to the ImportObject to create.
§Arguments
-
name
- The exported name of the table to add. -
table
- The wasm table instance to add.
Sourcepub fn build(self) -> ImportObject<Data>
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.