Struct Store

Source
pub struct Store<'m> { /* private fields */ }
Expand description

Runtime store.

Implementations§

Source§

impl<'m> Store<'m>

Source

pub fn id(&self) -> StoreId

Returns the identifier of this store.

Source

pub fn instantiate( &mut self, module: Module<'m>, memory: &'m mut [u8], ) -> Result<InstId, Error>

Instantiates a valid module in this store.

The memory is not dynamically allocated and must thus be provided. It is not necessary for the memory length to be a multiple of 64kB. Execution will trap if the module tries to access part of the memory that does not exist.

Source

pub fn invoke<'a>( &'a mut self, inst: InstId, name: &str, args: Vec<Val>, ) -> Result<RunResult<'a, 'm>, Error>

Invokes a function in an instance provided its name.

If a function was already running, it will resume once the function being called terminates. In other words, execution satisfies a stack property. Without this, the stack of the module may be corrupted.

Source

pub fn get_global(&mut self, inst: InstId, name: &str) -> Result<Val, Error>

Returns the value of a global of an instance.

Source

pub fn set_name(&mut self, inst: InstId, name: &'m str) -> Result<(), Error>

Sets the name of an instance.

Links a host function provided its signature.

This is a convenient wrapper around Self::link_func_custom() for functions which parameter and return types are only i32. The params and results parameters describe how many i32 are taken as parameters and returned as results respectively.

Enables linking unresolved imported function for the given module.

For each unresolved imported function type that returns exactly one i32, a fake host function is created (as if link_func was used). As such, out-of-bound indices with respect to real calls to Self::link_func() represent such fake host functions. Callers must thus expect and support out-of-bound indices returned by Call::index().

This function can be called at most once, and once called link_func cannot be called.

Links a host function provided its signature.

Note that the order in which functions are linked defines their index. The first linked function has index 0, the second has index 1, etc. This index is used when a module calls in the host to identify the function.

Source

pub fn last_call(&mut self) -> Option<Call<'_, 'm>>

Returns the call in the host, if any.

This function returns None if nothing is running.

Trait Implementations§

Source§

impl<'m> Debug for Store<'m>

Source§

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

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

impl Default for Store<'_>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<'m> Freeze for Store<'m>

§

impl<'m> RefUnwindSafe for Store<'m>

§

impl<'m> !Send for Store<'m>

§

impl<'m> !Sync for Store<'m>

§

impl<'m> Unpin for Store<'m>

§

impl<'m> !UnwindSafe for Store<'m>

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.