pub struct ImportModule<T: ?Sized> { /* private fields */ }
Expand description
An ImportModule represents a host module with a name. A host module consists of one or more host function, table, memory, and global instances, which are defined outside wasm modules and fed into wasm modules as imports.
Implementations§
Source§impl<T: Sized> ImportModule<T>
impl<T: Sized> ImportModule<T>
Sourcepub fn create(name: impl AsRef<str>, data: Box<T>) -> WasmEdgeResult<Self>
pub fn create(name: impl AsRef<str>, data: Box<T>) -> WasmEdgeResult<Self>
Creates a module instance which is used to import host functions, tables, memories, and globals into a wasm module.
§Argument
-
name
- The name of the import module instance. -
data
- The host context data used in this function.
§Error
If fail to create the import module instance, then an error is returned.
Sourcepub unsafe fn as_raw(&self) -> *mut WasmEdge_ModuleInstanceContext
pub unsafe fn as_raw(&self) -> *mut WasmEdge_ModuleInstanceContext
§Safety
Provides a raw pointer to the inner module instance context. The lifetime of the returned pointer must not exceed that of the object itself.
Sourcepub unsafe fn from_raw(ctx: *mut WasmEdge_ModuleInstanceContext) -> Self
pub unsafe fn from_raw(ctx: *mut WasmEdge_ModuleInstanceContext) -> Self
§Safety
This function will take over the lifetime management of ctx
, so do not call ffi::WasmEdge_ModuleInstanceDelete
on ctx
after this.
pub fn get_host_data(&self) -> &T
pub fn get_host_data_mut(&mut self) -> &mut T
Source§impl<T: Sized> ImportModule<T>
impl<T: Sized> ImportModule<T>
Trait Implementations§
Source§impl<T: Sized> AsInstance for ImportModule<T>
impl<T: Sized> AsInstance for ImportModule<T>
Source§fn get_table(
&self,
name: impl AsRef<str>,
) -> WasmEdgeResult<InnerRef<Table, &Self>>where
Self: Sized,
fn get_table(
&self,
name: impl AsRef<str>,
) -> WasmEdgeResult<InnerRef<Table, &Self>>where
Self: Sized,
Source§fn get_memory_ref(
&self,
name: impl AsRef<str>,
) -> WasmEdgeResult<InnerRef<Memory, &Self>>where
Self: Sized,
fn get_memory_ref(
&self,
name: impl AsRef<str>,
) -> WasmEdgeResult<InnerRef<Memory, &Self>>where
Self: Sized,
fn get_memory_mut(
&mut self,
name: impl AsRef<str>,
) -> WasmEdgeResult<InnerRef<Memory, &mut Self>>where
Self: Sized,
Source§fn get_global(
&self,
name: impl AsRef<str>,
) -> WasmEdgeResult<InnerRef<Global, &Self>>where
Self: Sized,
fn get_global(
&self,
name: impl AsRef<str>,
) -> WasmEdgeResult<InnerRef<Global, &Self>>where
Self: Sized,
fn get_global_mut(
&mut self,
name: impl AsRef<str>,
) -> WasmEdgeResult<InnerRef<Global, &mut Self>>where
Self: Sized,
Source§fn func_len(&self) -> u32
fn func_len(&self) -> u32
Source§fn func_names(&self) -> Option<Vec<String>>
fn func_names(&self) -> Option<Vec<String>>
Source§fn get_func(&self, name: &str) -> WasmEdgeResult<FuncRef<&Instance>>
fn get_func(&self, name: &str) -> WasmEdgeResult<FuncRef<&Instance>>
Source§fn get_func_mut(&mut self, name: &str) -> WasmEdgeResult<FuncRef<&mut Instance>>
fn get_func_mut(&mut self, name: &str) -> WasmEdgeResult<FuncRef<&mut Instance>>
Source§fn table_len(&self) -> u32
fn table_len(&self) -> u32
Source§fn table_names(&self) -> Option<Vec<String>>
fn table_names(&self) -> Option<Vec<String>>
Source§fn mem_len(&self) -> u32
fn mem_len(&self) -> u32
Source§fn mem_names(&self) -> Option<Vec<String>>
fn mem_names(&self) -> Option<Vec<String>>
Source§fn global_len(&self) -> u32
fn global_len(&self) -> u32
Source§fn global_names(&self) -> Option<Vec<String>>
fn global_names(&self) -> Option<Vec<String>>
Source§impl<T: Send> AsMut<ImportModule<T>> for AsyncImportObject<T>
Available on crate feature async
and Linux only.
impl<T: Send> AsMut<ImportModule<T>> for AsyncImportObject<T>
async
and Linux only.Source§fn as_mut(&mut self) -> &mut ImportModule<T>
fn as_mut(&mut self) -> &mut ImportModule<T>
Source§impl<T: Send> AsRef<ImportModule<T>> for AsyncImportObject<T>
Available on crate feature async
and Linux only.
impl<T: Send> AsRef<ImportModule<T>> for AsyncImportObject<T>
async
and Linux only.