Struct wasmedge_sys::WasiModule
source · pub struct WasiModule { /* private fields */ }
Expand description
A WasiModule is a module instance for the WASI specification.
Implementations§
source§impl WasiModule
impl WasiModule
sourcepub fn create(
args: Option<Vec<&str>>,
envs: Option<Vec<&str>>,
preopens: Option<Vec<&str>>
) -> WasmEdgeResult<Self>
pub fn create(
args: Option<Vec<&str>>,
envs: Option<Vec<&str>>,
preopens: Option<Vec<&str>>
) -> WasmEdgeResult<Self>
Creates a WASI host module which contains the WASI host functions, and initializes it with the given parameters.
Arguments
-
args
- The commandline arguments. The first argument is the program name. -
envs
- The environment variables in the formatENV_VAR_NAME=VALUE
. -
preopens
- The directories to pre-open. The required format isDIR1:DIR2
.
Error
If fail to create a host module, then an error is returned.
sourcepub fn init_wasi(
&mut self,
args: Option<Vec<&str>>,
envs: Option<Vec<&str>>,
preopens: Option<Vec<&str>>
)
pub fn init_wasi(
&mut self,
args: Option<Vec<&str>>,
envs: Option<Vec<&str>>,
preopens: Option<Vec<&str>>
)
Initializes the WASI host module with the given parameters.
Arguments
-
args
- The commandline arguments. The first argument is the program name. -
envs
- The environment variables in the formatENV_VAR_NAME=VALUE
. -
preopens
- The directories to pre-open. The required format isDIR1:DIR2
.
sourcepub fn exit_code(&self) -> u32
pub fn exit_code(&self) -> u32
Returns the WASI exit code.
The WASI exit code can be accessed after running the “_start” function of a wasm32-wasi
program.
sourcepub fn get_native_handler(&self, fd: i32) -> WasmEdgeResult<u64>
pub fn get_native_handler(&self, fd: i32) -> WasmEdgeResult<u64>
sourcepub fn as_ptr(&self) -> *const WasmEdge_ModuleInstanceContext
pub fn as_ptr(&self) -> *const WasmEdge_ModuleInstanceContext
Provides a raw pointer to the inner module instance context.
Trait Implementations§
source§impl AsImport for WasiModule
impl AsImport for WasiModule
source§fn add_func(&mut self, name: impl AsRef<str>, func: Function)
fn add_func(&mut self, name: impl AsRef<str>, func: Function)
source§fn add_table(&mut self, name: impl AsRef<str>, table: Table)
fn add_table(&mut self, name: impl AsRef<str>, table: Table)
source§fn add_memory(&mut self, name: impl AsRef<str>, memory: Memory)
fn add_memory(&mut self, name: impl AsRef<str>, memory: Memory)
source§fn add_global(&mut self, name: impl AsRef<str>, global: Global)
fn add_global(&mut self, name: impl AsRef<str>, global: Global)
source§impl AsInstance for WasiModule
impl AsInstance for WasiModule
source§fn func_len(&self) -> u32
fn func_len(&self) -> u32
Returns the length of the exported function instances in this module instance.
source§fn func_names(&self) -> Option<Vec<String>>
fn func_names(&self) -> Option<Vec<String>>
Returns the names of the exported function instances in this module instance.
source§fn table_len(&self) -> u32
fn table_len(&self) -> u32
Returns the length of the exported table instances in this module instance.
source§fn table_names(&self) -> Option<Vec<String>>
fn table_names(&self) -> Option<Vec<String>>
Returns the names of the exported table instances in this module instance.
source§fn mem_len(&self) -> u32
fn mem_len(&self) -> u32
Returns the length of the exported memory instances in this module instance.
source§fn mem_names(&self) -> Option<Vec<String>>
fn mem_names(&self) -> Option<Vec<String>>
Returns the names of all exported memory instances in this module instance.
source§fn global_len(&self) -> u32
fn global_len(&self) -> u32
Returns the length of the exported global instances in this module instance.
source§fn global_names(&self) -> Option<Vec<String>>
fn global_names(&self) -> Option<Vec<String>>
Returns the names of the exported global instances in this module instance.
source§fn get_func(&self, name: impl AsRef<str>) -> WasmEdgeResult<Function>
fn get_func(&self, name: impl AsRef<str>) -> WasmEdgeResult<Function>
source§fn get_table(&self, name: impl AsRef<str>) -> WasmEdgeResult<Table>
fn get_table(&self, name: impl AsRef<str>) -> WasmEdgeResult<Table>
source§fn get_memory(&self, name: impl AsRef<str>) -> WasmEdgeResult<Memory>
fn get_memory(&self, name: impl AsRef<str>) -> WasmEdgeResult<Memory>
source§fn get_global(&self, name: impl AsRef<str>) -> WasmEdgeResult<Global>
fn get_global(&self, name: impl AsRef<str>) -> WasmEdgeResult<Global>
source§impl Clone for WasiModule
impl Clone for WasiModule
source§fn clone(&self) -> WasiModule
fn clone(&self) -> WasiModule
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more