pub struct RuntimeInstance<'b, H = EmptyHookSet>{
pub hook_set: H,
pub store: Store<'b>,
}
Fields§
§hook_set: H
§store: Store<'b>
Implementations§
Source§impl<'b> RuntimeInstance<'b, EmptyHookSet>
impl<'b> RuntimeInstance<'b, EmptyHookSet>
pub fn new() -> Self
pub fn new_with_default_module( validation_info: &ValidationInfo<'b>, ) -> CustomResult<Self>
pub fn new_named( module_name: &str, validation_info: &ValidationInfo<'b>, ) -> CustomResult<Self>
Source§impl<'b, H> RuntimeInstance<'b, H>
impl<'b, H> RuntimeInstance<'b, H>
pub fn add_module( &mut self, module_name: &str, validation_info: &ValidationInfo<'b>, ) -> CustomResult<()>
pub fn new_with_hooks(hook_set: H) -> Self
pub fn get_function_by_name( &self, module_name: &str, function_name: &str, ) -> Result<FunctionRef, RuntimeError>
pub fn get_function_by_index( &self, module_addr: usize, function_idx: usize, ) -> Result<FunctionRef, RuntimeError>
Sourcepub fn invoke_typed<Params: InteropValueList, Returns: InteropValueList>(
&mut self,
function_ref: &FunctionRef,
params: Params,
) -> Result<Returns, RuntimeError>
pub fn invoke_typed<Params: InteropValueList, Returns: InteropValueList>( &mut self, function_ref: &FunctionRef, params: Params, ) -> Result<Returns, RuntimeError>
Invokes a function with the given parameters of type Param
, and return types of type Returns
.
Sourcepub fn invoke(
&mut self,
function_ref: &FunctionRef,
params: Vec<Value>,
) -> Result<Vec<Value>, RuntimeError>
pub fn invoke( &mut self, function_ref: &FunctionRef, params: Vec<Value>, ) -> Result<Vec<Value>, RuntimeError>
Invokes a function with the given parameters. The return types depend on the function signature.
Sourcepub fn add_host_function_typed<Params: InteropValueList, Returns: InteropValueList>(
&mut self,
module_name: &str,
name: &str,
host_func: fn(Vec<Value>) -> Vec<Value>,
) -> Result<FunctionRef, Error>
pub fn add_host_function_typed<Params: InteropValueList, Returns: InteropValueList>( &mut self, module_name: &str, name: &str, host_func: fn(Vec<Value>) -> Vec<Value>, ) -> Result<FunctionRef, Error>
Adds a host function under module namespace module_name
with name name
.
roughly similar to func_alloc
in https://webassembly.github.io/spec/core/appendix/embedding.html#functions
except the host function is made visible to other modules through these names.
pub fn add_host_function( &mut self, module_name: &str, name: &str, host_func_ty: FuncType, host_func: fn(Vec<Value>) -> Vec<Value>, ) -> Result<FunctionRef, Error>
Trait Implementations§
Source§impl<'b, H> Debug for RuntimeInstance<'b, H>
impl<'b, H> Debug for RuntimeInstance<'b, H>
Source§impl Default for RuntimeInstance<'_, EmptyHookSet>
impl Default for RuntimeInstance<'_, EmptyHookSet>
Auto Trait Implementations§
impl<'b, H> Freeze for RuntimeInstance<'b, H>where
H: Freeze,
impl<'b, H = EmptyHookSet> !RefUnwindSafe for RuntimeInstance<'b, H>
impl<'b, H> Send for RuntimeInstance<'b, H>where
H: Send,
impl<'b, H = EmptyHookSet> !Sync for RuntimeInstance<'b, H>
impl<'b, H> Unpin for RuntimeInstance<'b, H>where
H: Unpin,
impl<'b, H> UnwindSafe for RuntimeInstance<'b, H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more