Trait Instance

Source
pub trait Instance: Sized {
    type Runtime: Runtime;
    type UserData;
    type UserDataReference<'a>: Deref<Target = Self::UserData>
       where Self::UserData: 'a,
             Self: 'a;
    type UserDataMutReference<'a>: DerefMut<Target = Self::UserData>
       where Self::UserData: 'a,
             Self: 'a;

    // Required methods
    fn load_export(
        &mut self,
        name: &str,
    ) -> Option<<Self::Runtime as Runtime>::Export>;
    fn user_data(&self) -> Self::UserDataReference<'_>;
    fn user_data_mut(&mut self) -> Self::UserDataMutReference<'_>;
}
Expand description

An active guest Wasm module.

Required Associated Types§

Source

type Runtime: Runtime

The runtime this instance is running in.

Source

type UserData

Custom user data stored in the instance.

Source

type UserDataReference<'a>: Deref<Target = Self::UserData> where Self::UserData: 'a, Self: 'a

A reference to the custom user data stored in the instance.

Source

type UserDataMutReference<'a>: DerefMut<Target = Self::UserData> where Self::UserData: 'a, Self: 'a

A mutable reference to the custom user data stored in the instance.

Required Methods§

Source

fn load_export( &mut self, name: &str, ) -> Option<<Self::Runtime as Runtime>::Export>

Loads an export from the guest module.

Source

fn user_data(&self) -> Self::UserDataReference<'_>

Returns a reference to the custom user data stored in this instance.

Source

fn user_data_mut(&mut self) -> Self::UserDataMutReference<'_>

Returns a mutable reference to the custom user data stored in this instance.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<I> Instance for &mut I
where I: Instance,

Source§

type Runtime = <I as Instance>::Runtime

Source§

type UserData = <I as Instance>::UserData

Source§

type UserDataReference<'a> = <I as Instance>::UserDataReference<'a> where Self::UserData: 'a, Self: 'a

Source§

type UserDataMutReference<'a> = <I as Instance>::UserDataMutReference<'a> where Self::UserData: 'a, Self: 'a

Source§

fn load_export( &mut self, name: &str, ) -> Option<<Self::Runtime as Runtime>::Export>

Source§

fn user_data(&self) -> Self::UserDataReference<'_>

Source§

fn user_data_mut(&mut self) -> Self::UserDataMutReference<'_>

Implementors§

Source§

impl<UserData> Instance for StubInstance<UserData>

Source§

type Runtime = StubRuntime

Source§

type UserData = UserData

Source§

type UserDataReference<'a> = &'a UserData where Self::UserData: 'a, Self: 'a

Source§

type UserDataMutReference<'a> = &'a mut UserData where Self::UserData: 'a, Self: 'a