wasmedge_sys

Struct Loader

Source
pub struct Loader { /* private fields */ }
Expand description

Loader is used to load WASM modules from the given WASM files or buffers.

Implementations§

Source§

impl Loader

Source

pub fn create(config: Option<&Config>) -> WasmEdgeResult<Self>

Create a new Loader to be associated with the given global configuration.

§Arguments
  • config - A global configuration.
§Error

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

Source

pub fn from_file(&self, file: impl AsRef<Path>) -> WasmEdgeResult<Arc<Module>>

Loads a WASM module from a WASM file.

§Arguments
  • file - A wasm file or an AOT wasm file.
§Error

If fail to load, then an error is returned.

§Example
let file = "path/to/foo.wasm"
let module = loader.from_file(file)?;
Source

pub fn from_bytes(&self, bytes: impl AsRef<[u8]>) -> WasmEdgeResult<Arc<Module>>

Loads a WASM module from a in-memory bytes.

§Arguments
  • bytes - A in-memory WASM bytes.
§Error

If fail to load, then an error is returned.

§Example
let bytes = b"\0asm\x01\0\0\0";
let module = loader.from_bytes(&bytes)?;

Note that the text format is not accepted:

assert!(loader.from_bytes(b"(module)").is_err());

Trait Implementations§

Source§

impl Debug for Loader

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for Loader

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for Loader

§

impl RefUnwindSafe for Loader

§

impl Send for Loader

§

impl Sync for Loader

§

impl Unpin for Loader

§

impl UnwindSafe for Loader

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

Source§

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

Source§

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.