Struct option_lock::OptionLock[][src]

pub struct OptionLock<T> { /* fields omitted */ }
Expand description

A read/write lock around an Option value.

Implementations

impl<T> OptionLock<T>[src]

pub const fn empty() -> Self[src]

Create a new instance with no stored value.

pub const fn new(value: T) -> Self[src]

Create a new populated instance.

pub fn is_none_unlocked(&self) -> bool[src]

Check if there is no stored value and no guard held.

pub fn is_some_unlocked(&self) -> bool[src]

Check if there is a stored value and no guard held.

pub fn is_locked(&self) -> bool[src]

Check if a guard is held.

pub fn get_mut(&mut self) -> Option<&mut T>[src]

Get a mutable reference to the contained value, if any.

pub fn into_inner(self) -> Option<T>[src]

Unwrap an owned lock instance.

pub fn spin_get(&self) -> MutexGuard<'_, T>[src]

In a spin loop, wait to get an exclusive lock on the contained value.

pub fn spin_lock(&self) -> OptionGuard<'_, T>[src]

In a spin loop, wait to acquire the lock.

pub fn spin_lock_none(&self) -> OptionGuard<'_, T>[src]

In a spin loop, wait to acquire the lock with an empty slot.

pub fn spin_take(&self) -> T[src]

In a spin loop, wait to take a value from the lock.

pub fn try_get(&self) -> Result<MutexGuard<'_, T>, OptionLockError>[src]

Try to acquire an exclusive lock around a contained value.

On successful acquisition a MutexGuard<'_, T> is returned, representing an exclusive read/write lock.

pub fn try_get_arc(
    self: &Arc<Self>
) -> Result<MutexGuardArc<T>, OptionLockError>
[src]

Try to acquire an exclusive lock around the value in an Arc<OptionLock>.

On successful acquisition a MutexGuardArc<T> is returned, representing an exclusive read/write lock.

pub fn try_fill(&self, value: T) -> Result<(), T>[src]

Try to store a value, if the slot is currently empty and a lock can be acquired.

pub fn try_fill_with(
    &self,
    f: impl FnOnce() -> T
) -> Result<(), OptionLockError>
[src]

Store the result of an initializer function if the slot is currently empty and a lock can be acquired. If a lock cannot be acquired, then the initializer is never called.

pub fn try_lock(&self) -> Result<OptionGuard<'_, T>, OptionLockError>[src]

Try to acquire an exclusive lock.

On successful acquisition an OptionGuard<'_, T> is returned, representing an exclusive read/write lock.

pub fn try_lock_arc(
    self: &Arc<Self>
) -> Result<OptionGuardArc<T>, OptionLockError>
[src]

Try to acquire an exclusive lock from a reference to an Arc<OptionLock>.

On successful acquisition an OptionGuardArc<T> is returned, representing an exclusive read/write lock.

pub fn try_lock_none(&self) -> Result<OptionGuard<'_, T>, OptionLockError>[src]

Try to acquire an exclusive lock when there is no value currently stored.

pub fn try_lock_empty_arc(
    self: &Arc<Self>
) -> Result<OptionGuardArc<T>, OptionLockError>
[src]

Try to acquire an exclusive lock when there is no value currently stored.

pub fn try_take(&self) -> Result<T, OptionLockError>[src]

Try to take a stored value from the lock.

pub fn replace(&mut self, value: T) -> Option<T>[src]

Replace the value in an owned OptionLock.

pub fn take(&mut self) -> Option<T>[src]

Take the value (if any) from an owned OptionLock.

impl<T: Clone> OptionLock<T>[src]

pub fn try_clone(&self) -> Result<T, OptionLockError>[src]

Try to clone the contained resource.

impl<T: Copy> OptionLock<T>[src]

pub fn try_copy(&self) -> Result<T, OptionLockError>[src]

Try to copy the contained resource.

Trait Implementations

impl<T> Debug for OptionLock<T>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<T> Default for OptionLock<T>[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl<T> Drop for OptionLock<T>[src]

fn drop(&mut self)[src]

Executes the destructor for this type. Read more

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

fn from(data: Option<T>) -> Self[src]

Performs the conversion.

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

fn from(lock: OptionLock<T>) -> Self[src]

Performs the conversion.

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

fn from(data: T) -> Self[src]

Performs the conversion.

impl<T> Into<Option<T>> for OptionLock<T>[src]

fn into(self) -> Option<T>[src]

Performs the conversion.

impl<T: Send> Send for OptionLock<T>[src]

impl<T: Send> Sync for OptionLock<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for OptionLock<T>

impl<T> Unpin for OptionLock<T> where
    T: Unpin

impl<T> UnwindSafe for OptionLock<T> where
    T: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: !) -> T[src]

Performs the conversion.

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.