Struct wasmedge_sdk::Store

source ·
pub struct Store<'inst, T: ?Sized> { /* private fields */ }
Expand description

The Store is a collection of registered modules and assists wasm modules in finding the import modules they need.

Implementations§

source§

impl<'inst, T: AsInstance + ?Sized> Store<'inst, T>

source

pub fn new( config: Option<&Config>, instances: HashMap<String, &'inst mut T> ) -> WasmEdgeResult<Self>

Creates a new Store.

§Error

If fail to create a new Store, then an error is returned.

source

pub fn register_active_module( &mut self, module: &Module ) -> WasmEdgeResult<Instance>

Registers and instantiates a WasmEdge compiled module into this store as an anonymous active module instance, and returns the module instance.

§Arguments
  • executor - The executor that runs the host functions in this store.

  • module - The validated module to be registered.

§Error

If fail to register the given module, then an error is returned.

source

pub fn register_named_module( &mut self, name: impl AsRef<str>, module: &Module ) -> WasmEdgeResult<()>

source

pub fn named_instance_count(&self) -> usize

Returns the number of the named module instances in this store.

source

pub fn instance_names(&self) -> Vec<String>

Returns the names of all registered named module instances.

source

pub fn contains(&self, mod_name: impl AsRef<str>) -> bool

Checks if the store contains a named module instance.

§Argument
  • mod_name - The name of the named module.
source

pub fn get_instance_and_executor( &mut self, mod_name: impl AsRef<str> ) -> Option<(&mut T, &mut Executor)>

source

pub fn get_named_wasm_and_executor( &mut self, mod_name: impl AsRef<str> ) -> Option<(&mut Instance, &mut Executor)>

source

pub fn executor(&mut self) -> &mut Executor

Trait Implementations§

source§

impl<T: ?Sized> Debug for Store<'_, T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'inst, T> Freeze for Store<'inst, T>
where T: ?Sized,

§

impl<'inst, T> RefUnwindSafe for Store<'inst, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'inst, T> Send for Store<'inst, T>
where T: Send + ?Sized,

§

impl<'inst, T> Sync for Store<'inst, T>
where T: Sync + ?Sized,

§

impl<'inst, T> Unpin for Store<'inst, T>
where T: ?Sized,

§

impl<'inst, T> !UnwindSafe for Store<'inst, T>

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

§

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

§

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.