[−][src]Struct wasm3::Module
A loaded module belonging to a specific runtime. Allows for linking and looking up functions.
Implementations
impl<'rt> Module<'rt>
[src]
pub fn parse(environment: &Environment, bytes: &[u8]) -> Result<ParsedModule>
[src]
Parses a wasm module from raw bytes.
pub fn link_function<Args, Ret>(
&mut self,
module_name: &str,
function_name: &str,
f: RawCall
) -> Result<()> where
Args: WasmArgs,
Ret: WasmType,
[src]
&mut self,
module_name: &str,
function_name: &str,
f: RawCall
) -> Result<()> where
Args: WasmArgs,
Ret: WasmType,
Links the given function to the corresponding module and function name.
This allows linking a more verbose function, as it gets access to the unsafe
runtime parts. For easier use the make_func_wrapper
should be used to create
the unsafe facade for your function that then can be passed to this.
For a simple API see link_closure
which takes a closure instead.
Errors
This function will return an error in the following situations:
- a memory allocation failed
- no function by the given name in the given module could be found
- the function has been found but the signature did not match
pub fn link_closure<Args, Ret, F>(
&mut self,
module_name: &str,
function_name: &str,
closure: F
) -> Result<()> where
Args: WasmArgs,
Ret: WasmType,
F: for<'cc> FnMut(&'cc CallContext, Args) -> Ret + 'static,
[src]
&mut self,
module_name: &str,
function_name: &str,
closure: F
) -> Result<()> where
Args: WasmArgs,
Ret: WasmType,
F: for<'cc> FnMut(&'cc CallContext, Args) -> Ret + 'static,
Links the given closure to the corresponding module and function name. This boxes the closure and therefor requires a heap allocation.
Errors
This function will return an error in the following situations:
- a memory allocation failed
- no function by the given name in the given module could be found
- the function has been found but the signature did not match
pub fn find_function<Args, Ret>(
&self,
function_name: &str
) -> Result<Function<'rt, Args, Ret>> where
Args: WasmArgs,
Ret: WasmType,
[src]
&self,
function_name: &str
) -> Result<Function<'rt, Args, Ret>> where
Args: WasmArgs,
Ret: WasmType,
Looks up a function by the given name in this module.
Errors
This function will return an error in the following situations:
- a memory allocation failed
- no function by the given name in the given module could be found
- the function has been found but the signature did not match
pub fn function<Args, Ret>(
&self,
function_index: usize
) -> Result<Function<'rt, Args, Ret>> where
Args: WasmArgs,
Ret: WasmType,
[src]
&self,
function_index: usize
) -> Result<Function<'rt, Args, Ret>> where
Args: WasmArgs,
Ret: WasmType,
Looks up a function by its index in this module.
Errors
This function will return an error in the following situations:
- a memory allocation failed
- the index is out of bounds
- the function has been found but the signature did not match
pub fn name(&self) -> &str
[src]
The name of this module.
pub fn link_wasi(&mut self) -> Result<()>
[src]
Links wasi to this module.
pub fn link_libc(&mut self) -> Result<()>
[src]
Links libc to this module.
Auto Trait Implementations
impl<'rt> !RefUnwindSafe for Module<'rt>
impl<'rt> !Send for Module<'rt>
impl<'rt> !Sync for Module<'rt>
impl<'rt> Unpin for Module<'rt>
impl<'rt> !UnwindSafe for Module<'rt>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,