pub(crate) struct StoreContext {
id: StoreId,
borrow_count: u32,
entry: UnsafeCell<StoreContextEntry>,
}Fields§
§id: StoreId§borrow_count: u32§entry: UnsafeCell<StoreContextEntry>Implementations§
Source§impl StoreContext
impl StoreContext
fn is_active(id: StoreId) -> bool
fn is_suspended(id: StoreId) -> bool
fn install(id: StoreId, entry: StoreContextEntry)
Sourcepub(crate) fn install_async(
guard: LocalRwLockWriteGuard<Box<StoreInner>>,
) -> ForcedStoreInstallGuard
pub(crate) fn install_async( guard: LocalRwLockWriteGuard<Box<StoreInner>>, ) -> ForcedStoreInstallGuard
The write guard ensures this is the only reference to the store, so installation can never fail.
Sourcepub(crate) unsafe fn ensure_installed(
store_ptr: *mut StoreInner,
) -> StoreInstallGuard
pub(crate) unsafe fn ensure_installed( store_ptr: *mut StoreInner, ) -> StoreInstallGuard
Install the store context as sync if it is not already installed.
§Safety
The pointer must be dereferenceable and remain valid until the store context is uninstalled.
Sourcepub(crate) unsafe fn pause(id: StoreId) -> StorePtrPauseGuard
pub(crate) unsafe fn pause(id: StoreId) -> StorePtrPauseGuard
“Pause” one borrow of the store context.
§Safety
Code must ensure it does not use the StorePtrWrapper or StoreAsyncGuardWrapper that it owns, or any StoreRef/StoreMut derived from them, while the store context is paused.
The safe, correct use-case for this method is to
pause the store context while executing WASM code, which
cannot use the store context directly. This allows an async
context to uninstall the store context when suspending if it’s
called from a sync imported function. The imported function
will have borrowed the store context in its trampoline, which
will prevent the async context from uninstalling the store.
However, since the imported function passes a mutable borrow
of its store into Function::call, it will expect the store
to change before the call returns.
Sourcepub(crate) unsafe fn get_current(id: StoreId) -> StorePtrWrapper
pub(crate) unsafe fn get_current(id: StoreId) -> StorePtrWrapper
Safety: This method lets you borrow multiple mutable references to the currently active store context. The caller must ensure that:
- there is only one mutable reference alive, or
- all but one mutable reference are inaccessible and passed into a function that lost the reference (e.g. into WASM code)
The intended, valid use-case for this method is from within imported function trampolines.
Sourcepub(crate) unsafe fn get_current_transient(id: StoreId) -> *mut StoreInner
pub(crate) unsafe fn get_current_transient(id: StoreId) -> *mut StoreInner
Safety: In addition to the safety requirements of Self::get_current,
the pointer returned from this function will become invalid if
the store context is changed in any way (via installing or uninstalling
a store context). The caller must ensure that the store context
remains unchanged as long as the pointer is being accessed.
Sourcepub(crate) unsafe fn try_get_current(id: StoreId) -> Option<StorePtrWrapper>
pub(crate) unsafe fn try_get_current(id: StoreId) -> Option<StorePtrWrapper>
Safety: See Self::get_current.
Sourcepub(crate) unsafe fn try_get_current_async(
id: StoreId,
) -> GetStoreAsyncGuardResult
pub(crate) unsafe fn try_get_current_async( id: StoreId, ) -> GetStoreAsyncGuardResult
Safety: See Self::get_current.
Auto Trait Implementations§
impl !Freeze for StoreContext
impl !RefUnwindSafe for StoreContext
impl !Send for StoreContext
impl !Sync for StoreContext
impl Unpin for StoreContext
impl !UnwindSafe for StoreContext
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more