Struct RuntimeInstance

Source
pub struct RuntimeInstance<'b, H = EmptyHookSet>
where H: HookSet + Debug,
{ pub hook_set: H, pub store: Store<'b>, }

Fields§

§hook_set: H§store: Store<'b>

Implementations§

Source§

impl<'b> RuntimeInstance<'b, EmptyHookSet>

Source

pub fn new() -> Self

Source

pub fn new_with_default_module( validation_info: &ValidationInfo<'b>, ) -> CustomResult<Self>

Source

pub fn new_named( module_name: &str, validation_info: &ValidationInfo<'b>, ) -> CustomResult<Self>

Source§

impl<'b, H> RuntimeInstance<'b, H>
where H: HookSet + Debug,

Source

pub fn add_module( &mut self, module_name: &str, validation_info: &ValidationInfo<'b>, ) -> CustomResult<()>

Source

pub fn new_with_hooks(hook_set: H) -> Self

Source

pub fn get_function_by_name( &self, module_name: &str, function_name: &str, ) -> Result<FunctionRef, RuntimeError>

Source

pub fn get_function_by_index( &self, module_addr: usize, function_idx: usize, ) -> Result<FunctionRef, RuntimeError>

Source

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.

Source

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.

Source

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.

Source

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>
where H: HookSet + Debug + Debug,

Source§

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

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

impl Default for RuntimeInstance<'_, EmptyHookSet>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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