pub trait ContextProvider {
type Context: Sized;
// Required method
fn context(&mut self) -> &mut Self::Context;
}
Expand description
A type that provides a context implementation.
This trait allows for CtxPair
to hold context implementations
agnostically of the storage method and how they’re implemented. For example,
tests usually create API structs with a mutable borrow to contexts, while
the core context exposed to bindings is implemented on an owned [CoreCtx
]
type.
The shape of this trait is equivalent to core::ops::DerefMut
but we
decide against using that because of the automatic dereferencing semantics
the compiler provides around implementers of DerefMut
.