TBBackGuard

Struct TBBackGuard 

Source
pub struct TBBackGuard<'a, T> { /* private fields */ }
Expand description

An RAII guard holding a lock on the back buffer.

The back buffer can be accessed via the back and back_mut methods and committed with the swap method. After swapping, the back buffer will be in an indeterminate state and may be either the previous front buffer or previous pending buffer. Usually callers should ensure the back buffer is fully cleared or rewritten after acquiring the lock and before calling swap. Dropping the guard structure without calling swap will unlock the back buffer, leaving it in the same state for the next time it’s locked.

The pending and pending_mut methods can also be used to access the pending buffer if it was not locked at the time this structure was created. The primary reason to access the pending is to free data in the pending buffer without having to wait for the next swap.

Implementations§

Source§

impl<T> TBBackGuard<'_, T>

Source

pub fn back(&self) -> &T

Returns a reference to the back buffer.

Source

pub fn back_mut(&mut self) -> &mut T

Returns a mutable reference to the back buffer.

Source

pub fn pending(&self) -> Option<&T>

Returns a reference to the pending buffer, or None if the pending buffer was locked at the time the structure was created.

Source

pub fn pending_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the pending buffer, or None if the pending buffer was locked at the time the structure was created.

Source

pub fn swap(self)

Swaps the back buffer with the pending buffer and then locks the pending buffer if it was not already locked.

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for TBBackGuard<'a, T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T: Display> Display for TBBackGuard<'_, T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<T> Drop for TBBackGuard<'_, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: Send> Send for TBBackGuard<'_, T>

Source§

impl<T: Send + Sync> Sync for TBBackGuard<'_, T>

Auto Trait Implementations§

§

impl<'a, T> Freeze for TBBackGuard<'a, T>

§

impl<'a, T> !RefUnwindSafe for TBBackGuard<'a, T>

§

impl<'a, T> Unpin for TBBackGuard<'a, T>

§

impl<'a, T> !UnwindSafe for TBBackGuard<'a, T>

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.