Skip to main content

Guard

Struct Guard 

Source
pub struct Guard<'lock_mem, 'facet> { /* private fields */ }
Expand description

Contains the guard, the data ptr, and drop vtable to free the lock

§Note

The contained MaybeMut is NOT guaranteed to be Mut

For example, RwLock also needs a lock and guard for a read.

Implementations§

Source§

impl<'lock, 'facet> Guard<'lock, 'facet>

Source

pub fn shape(&self) -> &'static Shape

Returns the Shape of the underlying MaybeMut

Source

pub fn as_peek<'s>(&'s self) -> Peek<'s, 'facet>

It is always possible to get a Peek from a Guard

Source

pub fn as_poke<'s>(&'s mut self) -> Option<Poke<'s, 'facet>>

If the Guard contains a Poke, this will return Some(Poke) assuming Poke can be reborrowed.

Source

pub fn as_maybe<'s>(&'s mut self) -> MaybeMut<'s, 'facet>

Returns either a Poke or a Peek depending on whats available via the guard (read lock or write lock)

Trait Implementations§

Source§

impl Drop for Guard<'_, '_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<'lock_mem, 'facet> !Send for Guard<'lock_mem, 'facet>

§

impl<'lock_mem, 'facet> !Sync for Guard<'lock_mem, 'facet>

§

impl<'lock_mem, 'facet> !UnwindSafe for Guard<'lock_mem, 'facet>

§

impl<'lock_mem, 'facet> Freeze for Guard<'lock_mem, 'facet>

§

impl<'lock_mem, 'facet> RefUnwindSafe for Guard<'lock_mem, 'facet>

§

impl<'lock_mem, 'facet> Unpin for Guard<'lock_mem, 'facet>

§

impl<'lock_mem, 'facet> UnsafeUnpin for Guard<'lock_mem, 'facet>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.