pub fn from_file(&self, path: impl AsRef<Path>) -> WasmEdgeResult<Module> {
        let c_path = utils::path_to_cstring(path.as_ref())?;
        let mut mod_ctx = std::ptr::null_mut();
        unsafe {
            check(wasmedge::WasmEdge_LoaderParseFromFile(
                self.inner.0,
                &mut mod_ctx,
                c_path.as_ptr(),
            ))?;
        }

        match mod_ctx.is_null() {
            true => Err(WasmEdgeError::ModuleCreate),
            false => Ok(Module {
                inner: InnerModule(mod_ctx),
            }),
        }
    }
/// Loads a WASM module from a WASM file with the suffix ".wasm".
///
/// # Arguments
///
/// - `path` specifies the file path to the target WASM file.
///
/// # Error
///
/// If fail to load, then an error is returned.
///
/// # Example
///
/// ```ignore
/// let file = "path/to/foo.wasm"
/// let module = loader.from_file(file)?;
/// ```
Loads a WASM module from a WASM file with the suffix ".wasm".
Loads a WASM module from a WASM file with the suffix " . wasm " .
pub fn from_file(&self, path: impl AsRef<Path>) -> WasmEdgeResult<Module> {
        let c_path = utils::path_to_cstring(path.as_ref())?;
        let mut mod_ctx = std::ptr::null_mut();
        unsafe {
            check(wasmedge::WasmEdge_LoaderParseFromFile(
                self.inner.0,
                &mut mod_ctx,
                c_path.as_ptr(),
            ))?;
        }
        match mod_ctx.is_null() {
            true => Err(WasmEdgeError::ModuleCreate),
            false => Ok(Module {
                inner: InnerModule(mod_ctx),
            }),
        }
    }
pub fn from_file ( & self , path : impl AsRef < Path > ) -> WasmEdgeResult < Module > { let c_path = utils :: path_to_cstring ( path . as_ref ( ) ) ? ; let mut mod_ctx = std :: ptr :: null_mut ( ) ; unsafe { check ( wasmedge :: WasmEdge_LoaderParseFromFile ( self . inner . 0 , & mut mod_ctx , c_path . as_ptr ( ) , ) ) ? ; } match mod_ctx . is_null ( ) { true => Err ( WasmEdgeError :: ModuleCreate ) , false => Ok ( Module { inner : InnerModule ( mod_ctx ) , } ) , } }
Loads a WASM module from a WASM file with the suffix ".wasm".
Loads a WASM module from a WASM file with the suffix " . wasm " .
&self
path
impl AsRef<Path>
&self
path
impl AsRef<Path>
specifies the file path to the target WASM file.
specifies the file path to the target WASM file .
error
If fail to load, then an error is returned.
If fail to load then an error is returned .
example
```ignore
let file = "path/to/foo.wasm"
let module = loader.from_file(file)?;
```
` ` ` ignore let file = " path / to / foo . wasm " let module = loader . from_file ( file ) ? ; ` ` `