Struct wasmedge_sdk::Module

source ·
pub struct Module { /* private fields */ }
Expand description

Defines compiled in-memory representation of an input WASM binary.

A Module is a compiled in-memory representation of an input WebAssembly binary. In the instantiation process, a Module is instatiated to a module instance, from which the exported function, table, memory, and global instances can be fetched.

Implementations§

source§

impl Module

source

pub fn from_file( config: Option<&Config>, file: impl AsRef<Path> ) -> WasmEdgeResult<Self>

Returns a validated module from a file.

Arguments
  • config - The global configuration.

  • file - A wasm file or an AOT wasm file.

Error

If fail to load and valiate a module from a file, returns an error.

source

pub fn from_bytes( config: Option<&Config>, bytes: impl AsRef<[u8]> ) -> WasmEdgeResult<Self>

Loads a WebAssembly binary module from in-memory bytes.

Arguments
  • config - The global configuration.

  • bytes - The in-memory bytes to be parsed.

Error

If fail to load and valiate the WebAssembly module from the given in-memory bytes, returns an error.

source

pub fn count_of_imports(&self) -> u32

Returns the count of the imported WasmEdge instances in the module.

source

pub fn imports(&self) -> Vec<ImportType<'_>>

Returns the import types of all imported WasmEdge instances in the module.

source

pub fn count_of_exports(&self) -> u32

Returns the count of the exported WasmEdge instances from the module.

source

pub fn exports(&self) -> Vec<ExportType<'_>>

Returns the export types of all exported WasmEdge instances (including funcs, tables, globals and memories) from the module.

source

pub fn get_export(&self, name: impl AsRef<str>) -> Option<ExternalInstanceType>

Gets the export type by the name of a specific exported WasmEdge instance, such as func, table, global or memory instance.

Argument
  • name - The name of the target exported WasmEdge instance, such as func, table, global or memory instance.

Trait Implementations§

source§

impl Clone for Module

source§

fn clone(&self) -> Module

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Module

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V