pub trait AsAccessor {
type Data: 'static;
type AccessorData: HasData + ?Sized;
// Required method
fn as_accessor(&self) -> &Accessor<Self::Data, Self::AccessorData>;
}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
StoreContextMut::run_concurrent for example or in a host function
through
Linker::func_wrap_concurrent.
Required Associated Types§
Sourcetype AccessorData: HasData + ?Sized
type AccessorData: HasData + ?Sized
The D in Accessor<T, D>, or the projection out of
Self::Data.
Required Methods§
Sourcefn as_accessor(&self) -> &Accessor<Self::Data, Self::AccessorData>
fn as_accessor(&self) -> &Accessor<Self::Data, Self::AccessorData>
Returns the accessor that this is referring to.