Struct RuntimeInstance

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

Fields§

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

Implementations§

Source§

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

Source

pub fn new(user_data: T) -> Self

Source

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

Source

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

Source§

impl<'b, T, H> RuntimeInstance<'b, T, 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(user_data: T, 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(&mut T, 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(&mut T, Vec<Value>) -> Vec<Value>, ) -> Result<FunctionRef, Error>

Source

pub fn user_data(&self) -> &T

Source

pub fn user_data_mut(&mut self) -> &mut T

Trait Implementations§

Source§

impl<'b, T: Debug, H> Debug for RuntimeInstance<'b, T, 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<T: Default> Default for RuntimeInstance<'_, T, EmptyHookSet>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'b, T, H> Freeze for RuntimeInstance<'b, T, H>
where H: Freeze, T: Freeze,

§

impl<'b, T = (), H = EmptyHookSet> !RefUnwindSafe for RuntimeInstance<'b, T, H>

§

impl<'b, T, H> Send for RuntimeInstance<'b, T, H>
where H: Send, T: Send,

§

impl<'b, T = (), H = EmptyHookSet> !Sync for RuntimeInstance<'b, T, H>

§

impl<'b, T, H> Unpin for RuntimeInstance<'b, T, H>
where H: Unpin, T: Unpin,

§

impl<'b, T, H> UnwindSafe for RuntimeInstance<'b, T, H>
where H: UnwindSafe, T: 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.