wasmedge_sdk

Struct Compiler

Source
pub struct Compiler { /* private fields */ }
Available on crate feature aot only.
Expand description

Defines WasmEdge ahead-of-time(AOT) compiler and the relevant APIs.

Implementations§

Source§

impl Compiler

Source

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

Creates a new AOT compiler.

§Error

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

Source

pub fn compile_from_file( &self, wasm_file: impl AsRef<Path>, filename: impl AsRef<str>, out_dir: impl AsRef<Path>, ) -> WasmEdgeResult<PathBuf>

Compiles the given wasm file into a shared library file (*.so in Linux, *.dylib in macOS, or *.dll in Windows). The file path of the generated shared library file will be returned if the method works successfully.

§Arguments
  • wasm_file - The target wasm file.

  • filename - The filename of the generated shared library file.

  • out_dir - The target directory to save the generated shared library file.

§Error

If fail to compile, then an error is returned.

Source

pub fn compile_from_bytes( &self, bytes: impl AsRef<[u8]>, filename: impl AsRef<str>, out_dir: impl AsRef<Path>, ) -> WasmEdgeResult<PathBuf>

Compiles the given wasm bytes into a shared library file (*.so in Linux, *.dylib in macOS, or *.dll in Windows). The file path of the generated shared library file will be returned if the method works successfully.

§Argument
  • bytes - A in-memory WASM bytes.

  • filename - The filename of the generated shared library file.

  • out_dir - The target directory to save the generated shared library file.

§Error

If fail to compile, then an error is returned.

Trait Implementations§

Source§

impl Debug for Compiler

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