Struct tokenlock::SingletonTokenGuard[][src]

pub struct SingletonTokenGuard<Tag: ?Sized + SingletonTokenFactory, Variant = SyncVariant> { /* fields omitted */ }

The RAII guard for a SingletonToken obtained through SingletonToken::new. Returns the token to the factory automatically when dropped.

The second type parameter (Variant) is internal use only and exempt from the API stability guarantee.

Implementations

impl<Tag: ?Sized + SingletonTokenFactory> SingletonTokenGuard<Tag>[src]

pub fn into_unsync(self) -> UnsyncSingletonTokenGuard<Tag>[src]

Convert SingletonTokenGuard to the !Sync variant.

impl<Tag: ?Sized + SingletonTokenFactory> SingletonTokenGuard<Tag, UnsyncVariant>[src]

pub fn into_sync(self) -> SingletonTokenGuard<Tag>[src]

Convert UnsyncSingletonToken to the Sync variant.

Methods from Deref<Target = SingletonToken<Tag, Variant>>

pub fn id(&self) -> SingletonTokenId<Tag>[src]

Construct an SingletonTokenId that equates to self.

pub fn borrow(&self) -> SingletonTokenRef<'_, Tag, Variant>[src]

Borrow self as SingletonTokenRef or UnsyncSingletonTokenRef of the same Sync-ness as Self.

SingletonTokenRef is truly zero-sized, so it's more efficient to store and pass than &SingletonToken.

pub fn borrow_mut(&mut self) -> SingletonTokenRefMut<'_, Tag, Variant>[src]

Borrow self mutably as SingletonTokenRefMut or UnsyncSingletonTokenRefMut of the same Sync-ness as Self.

SingletonTokenRefMut is truly zero-sized, so it's more efficient to store and pass than &mut SingletonToken.

pub fn borrow_sync(&self) -> SingletonTokenRef<'_, Tag>[src]

Borrow self: UnsyncSingletonToken as SingletonTokenRef.

pub fn borrow_sync_mut(&mut self) -> SingletonTokenRefMut<'_, Tag>[src]

Borrow self: UnsyncSingletonToken mutably as SingletonTokenRefMut.

pub fn borrow_unsync_mut(&mut self) -> UnsyncSingletonTokenRefMut<'_, Tag>[src]

Borrow self: SingletonToken mutably as UnsyncSingletonTokenRefMut.

There is no borrow_unsync because that would allow UnsyncSingletonToken to be logically borrowed by multiple threads.

Trait Implementations

impl<Tag: ?Sized + SingletonTokenFactory, Variant: SingletonTokenVariant> Deref for SingletonTokenGuard<Tag, Variant>[src]

type Target = SingletonToken<Tag, Variant>

The resulting type after dereferencing.

impl<Tag: ?Sized + SingletonTokenFactory, Variant: SingletonTokenVariant> DerefMut for SingletonTokenGuard<Tag, Variant>[src]

impl<Tag: ?Sized + SingletonTokenFactory, Variant> Drop for SingletonTokenGuard<Tag, Variant>[src]

Auto Trait Implementations

impl<Tag: ?Sized, Variant> RefUnwindSafe for SingletonTokenGuard<Tag, Variant> where
    Variant: RefUnwindSafe
[src]

impl<Tag: ?Sized, Variant> Send for SingletonTokenGuard<Tag, Variant> where
    Variant: Send
[src]

impl<Tag: ?Sized, Variant> Sync for SingletonTokenGuard<Tag, Variant> where
    Variant: Sync
[src]

impl<Tag: ?Sized, Variant> Unpin for SingletonTokenGuard<Tag, Variant> where
    Variant: Unpin
[src]

impl<Tag: ?Sized, Variant> UnwindSafe for SingletonTokenGuard<Tag, Variant> where
    Variant: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.