Struct wasmtime::component::Instance

source ·
pub struct Instance(/* private fields */);
Available on crate features 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

source

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.

source

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.

source

pub fn get_typed_func<Params, Results>( &self, store: impl AsContextMut, name: &str ) -> Result<TypedFunc<Params, Results>>
where Params: ComponentNamedList + Lower, Results: ComponentNamedList + Lift,

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.

source

pub fn get_module(&self, store: impl AsContextMut, name: &str) -> Option<Module>

Looks up a module 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 module is found Some is returned otherwise None is returned.

§Panics

Panics if store does not own this instance.

source

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§

source§

impl Clone for Instance

source§

fn clone(&self) -> Instance

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Copy for Instance

Auto Trait Implementations§

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.