Struct soroban_wasmi::Instance
source · pub struct Instance(/* private fields */);
Expand description
An instantiated WebAssembly Module
.
This type represents an instantiation of a Module
.
It primarily allows to access its exports
to call functions, get or set globals, read or write memory, etc.
When interacting with any Wasm code you will want to create an
Instance
in order to execute anything.
Instances are owned by a Store
.
Create new instances using Linker::instantiate
.
Implementations§
source§impl Instance
impl Instance
sourcepub fn get_typed_func<Params, Results>(
&self,
store: impl AsContext,
name: &str
) -> Result<TypedFunc<Params, Results>, Error>where
Params: WasmParams,
Results: WasmResults,
pub fn get_typed_func<Params, Results>(
&self,
store: impl AsContext,
name: &str
) -> Result<TypedFunc<Params, Results>, Error>where
Params: WasmParams,
Results: WasmResults,
Looks up an exported Func
value by name
.
Returns None
if there was no export named name
,
or if there was but it wasn’t a function.
§Errors
- If there is no export named
name
. - If there is no exported function named
name
. - If
Params
orResults
do not match the exported function type.
§Panics
If store
does not own this Instance
.
sourcepub fn exports<'ctx, T: 'ctx>(
&self,
store: impl Into<StoreContext<'ctx, T>>
) -> ExportsIter<'ctx> ⓘ
pub fn exports<'ctx, T: 'ctx>( &self, store: impl Into<StoreContext<'ctx, T>> ) -> ExportsIter<'ctx> ⓘ
Trait Implementations§
source§impl PartialEq for Instance
impl PartialEq for Instance
impl Copy for Instance
impl Eq for Instance
impl StructuralEq for Instance
impl StructuralPartialEq for Instance
Auto Trait Implementations§
impl RefUnwindSafe for Instance
impl Send for Instance
impl Sync for Instance
impl Unpin for Instance
impl UnwindSafe for Instance
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.