pub struct Instance(/* private fields */);runtime and component-model only.Expand description
An instantiated component.
This type represents an instantiated Component.
Instances have exports which can be accessed through functions such as
Instance::get_func or Instance::exports. Instances are owned by a
Store and all methods require a handle to the store.
Component instances are created through
Linker::instantiate and its family of
methods.
This type is similar to the core wasm version
wasmtime::Instance except that it represents an
instantiated component instead of an instantiated module.
Implementations§
source§impl Instance
impl Instance
sourcepub fn exports<'a, T: 'a>(
&self,
store: impl Into<StoreContextMut<'a, T>>
) -> Exports<'a>
pub fn exports<'a, T: 'a>( &self, store: impl Into<StoreContextMut<'a, T>> ) -> Exports<'a>
Returns information about the exports of this instance.
This method can be used to extract exported values from this component instance. The argument to this method be a handle to the store that this instance was instantiated into.
The returned Exports value can be used to lookup exported items by
name.
§Panics
Panics if store does not own this instance.
sourcepub fn get_func(&self, store: impl AsContextMut, name: &str) -> Option<Func>
pub fn get_func(&self, store: impl AsContextMut, name: &str) -> Option<Func>
Looks up a function by name within this Instance.
This is a convenience method for calling Instance::exports followed
by ExportInstance::func.
§Panics
Panics if store does not own this instance.
sourcepub fn get_typed_func<Params, Results>(
&self,
store: impl AsContextMut,
name: &str
) -> Result<TypedFunc<Params, Results>>
pub fn get_typed_func<Params, Results>( &self, store: impl AsContextMut, name: &str ) -> Result<TypedFunc<Params, Results>>
Looks up an exported Func value by name and with its type.
This function is a convenience wrapper over Instance::get_func and
Func::typed. For more information see the linked documentation.
Returns an error if name isn’t a function export or if the export’s
type did not match Params or Results
§Panics
Panics if store does not own this instance.
sourcepub fn get_module(&self, store: impl AsContextMut, name: &str) -> Option<Module>
pub fn get_module(&self, store: impl AsContextMut, name: &str) -> Option<Module>
sourcepub fn get_resource(
&self,
store: impl AsContextMut,
name: &str
) -> Option<ResourceType>
pub fn get_resource( &self, store: impl AsContextMut, name: &str ) -> Option<ResourceType>
Looks up an exported resource type by name within this Instance.
The store specified must be the store that this instance lives within
and name is the name of the function to lookup. If the resource type
is found Some is returned otherwise None is returned.
§Panics
Panics if store does not own this instance.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Instance
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
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more