Skip to main content

AsAccessor

Trait AsAccessor 

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

    // Required method
    fn as_accessor(&self) -> &Accessor<Self::Data, Self::AccessorData>;
}
Available on crate features component-model-async and component-model and runtime 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.

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 StoreContextMut::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 + ?Sized

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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

Implementors§