Trait AsAccessor

Source
pub trait AsAccessor {
    type Data: 'static;
    type AccessorData: HasData;

    // Required method
    fn as_accessor(&self) -> &Accessor<Self::Data, Self::AccessorData>;
}
Available on crate features runtime and component-model and component-model-async only.
Expand description

A helper trait to take any type of accessor-with-data in functions.

This trait is similar to AsContextMut except that it’s used when working with an Accessor instead of a StoreContextMut. The Accessor is the main type used in concurrent settings and is passed to functions such as Func::call_concurrent or FutureWriter::write.

This trait is implemented for Accessor and &T where T implements this trait. This effectively means that regardless of the D in Accessor<T, D> it can still be passed to a function which just needs a store accessor.

Acquiring an Accessor can be done through Instance::run_concurrent for example or in a host function through Linker::func_wrap_concurrent.

Required Associated Types§

Source

type Data: 'static

The T in Store<T> that this accessor refers to.

Source

type AccessorData: HasData

The D in Accessor<T, D>, or the projection out of Self::Data.

Required Methods§

Source

fn as_accessor(&self) -> &Accessor<Self::Data, Self::AccessorData>

Returns the accessor that this is referring to.

Implementations on Foreign Types§

Source§

impl<T: AsAccessor + ?Sized> AsAccessor for &T

Implementors§