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

source

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 format ENV_VAR_NAME=VALUE.

  • preopens - The directories to pre-open. The required format is GUEST_PATH:HOST_PATH.

§Error

If fail to create a host module, then an error is returned.

source

pub fn name(&self) -> &str

Returns the name of the module instance.

source

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 format ENV_VAR_NAME=VALUE.

  • preopens - The directories to pre-open. The required format is GUEST_PATH:HOST_PATH.

source

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.

source

pub fn get_native_handler(&self, fd: i32) -> WasmEdgeResult<u64>

Returns the native handler from the mapped FD/Handler.

§Argument
  • fd - The WASI mapped Fd.
§Error

If fail to get the native handler, then an error is returned.

Trait Implementations§

source§

impl AsMut<Instance> for WasiModule

source§

fn as_mut(&mut self) -> &mut Instance

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<Instance> for WasiModule

source§

fn as_ref(&self) -> &Instance

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Debug for WasiModule

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<Inst> AsInstance for Inst
where Inst: AsMut<Instance> + AsRef<Instance>,

source§

unsafe fn as_ptr(&self) -> *const WasmEdge_ModuleInstanceContext

Safety Read more
source§

fn name(&self) -> Option<String>

Returns the name of this exported module instance. Read more
source§

fn get_table( &self, name: impl AsRef<str> ) -> WasmEdgeResult<InnerRef<Table, &Self>>
where Self: Sized,

Returns the exported table instance by name. Read more
source§

fn get_memory_ref( &self, name: impl AsRef<str> ) -> WasmEdgeResult<InnerRef<Memory, &Self>>
where Self: Sized,

Returns the exported memory instance by name. Read more
source§

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,

Returns the exported global instance by name. Read more
source§

fn get_global_mut( &mut self, name: impl AsRef<str> ) -> WasmEdgeResult<InnerRef<Global, &mut Self>>
where Self: Sized,

source§

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

Returns the names of the exported function instances in this module instance.
source§

fn get_func(&self, name: &str) -> WasmEdgeResult<FuncRef<&Instance>>

Returns the exported function instance by name. Read more
source§

fn get_func_mut(&mut self, name: &str) -> WasmEdgeResult<FuncRef<&mut Instance>>

Returns the exported function instance by name. Read more
source§

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

Returns the names of the exported table instances in this module instance.
source§

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

Returns the names of all exported memory instances in this module instance.
source§

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

Returns the names of the exported global instances in this module instance.
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.