pub(crate) struct Token<'a, T: 'a> {
level: PhantomData<&'a *const T>,
}
Expand description
A zero-size permission token to lock some fields of Hub
.
Access to a Token<T>
grants permission to lock any field of
Hub
following the one of type [Registry<T, ...>
], where
“following” is as defined by the Access
implementations.
Calling Token::root()
returns a Token<Root>
, which grants
permission to lock any field. Dynamic checks ensure that each
thread has at most one Token<Root>
live at a time, in debug
builds.
The locking methods on Registry<T, ...>
take a &'t mut Token<A>
, and return a fresh Token<'t, T>
and a lock guard with
lifetime 't
, so the caller cannot access their Token<A>
again
until they have dropped both the Token<T>
and the lock guard.
Tokens are !Send
, so one thread can’t send its permissions to
another.
Fields§
§level: PhantomData<&'a *const T>
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> RefUnwindSafe for Token<'a, T>where T: RefUnwindSafe,
impl<'a, T> !Send for Token<'a, T>
impl<'a, T> !Sync for Token<'a, T>
impl<'a, T> Unpin for Token<'a, T>
impl<'a, T> UnwindSafe for Token<'a, T>where T: RefUnwindSafe,
Blanket Implementations§
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
Mutably borrows from an owned value. Read more