Struct arc_swap::Guard

source ·
pub struct Guard<T: RefCnt, S: Strategy<T> = DefaultStrategy> { /* private fields */ }
Expand description

A temporary storage of the pointer.

This guard object is returned from most loading methods (with the notable exception of load_full). It dereferences to the smart pointer loaded, so most operations are to be done using that.

Implementations§

source§

impl<T: RefCnt, S: Strategy<T>> Guard<T, S>

source

pub fn into_inner(lease: Self) -> T

Converts it into the held value.

This, on occasion, may be a tiny bit faster than cloning the Arc or whatever is being held inside.

source

pub fn from_inner(inner: T) -> Self

Create a guard for a given value inner.

This can be useful on occasion to pass a specific object to code that expects or wants to store a Guard.

§Example
// Create two guards pointing to the same object
let g1 = p.load();
let g2 = Guard::<_, DefaultStrategy>::from_inner(Arc::clone(&*g1));

Trait Implementations§

source§

impl<'a, T: RefCnt> AsRaw<<T as RefCnt>::Base> for &'a Guard<T>

source§

fn as_raw(&self) -> *mut T::Base

Converts the value into a raw pointer.
source§

impl<T: RefCnt> AsRaw<<T as RefCnt>::Base> for Guard<T>

source§

fn as_raw(&self) -> *mut T::Base

Converts the value into a raw pointer.
source§

impl<T: Debug + RefCnt, S: Strategy<T>> Debug for Guard<T, S>

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> FmtResult

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

impl<T: Default + RefCnt, S: Strategy<T>> Default for Guard<T, S>

source§

fn default() -> Self

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

impl<T: RefCnt, S: Strategy<T>> Deref for Guard<T, S>

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &T

Dereferences the value.
source§

impl<T: Display + RefCnt, S: Strategy<T>> Display for Guard<T, S>

source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> FmtResult

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

impl<T: RefCnt, S: Strategy<T>> From<T> for Guard<T, S>

source§

fn from(inner: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T, S> Freeze for Guard<T, S>
where <S as InnerStrategy<T>>::Protected: Freeze,

§

impl<T, S> RefUnwindSafe for Guard<T, S>
where <S as InnerStrategy<T>>::Protected: RefUnwindSafe,

§

impl<T, S> Send for Guard<T, S>
where <S as InnerStrategy<T>>::Protected: Send,

§

impl<T, S> Sync for Guard<T, S>
where <S as InnerStrategy<T>>::Protected: Sync,

§

impl<T, S> Unpin for Guard<T, S>
where <S as InnerStrategy<T>>::Protected: Unpin,

§

impl<T, S> UnwindSafe for Guard<T, S>
where <S as InnerStrategy<T>>::Protected: UnwindSafe,

Blanket Implementations§

source§

impl<T, A, P> Access<T> for P
where A: Access<T> + ?Sized, P: Deref<Target = A>,

§

type Guard = <A as Access<T>>::Guard

A guard object containing the value and keeping it alive. Read more
source§

fn load(&self) -> <P as Access<T>>::Guard

The loading method. Read more
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, A> DynAccess<T> for A
where A: Access<T>, <A as Access<T>>::Guard: 'static,

source§

fn load(&self) -> DynGuard<T>

The equivalent of Access::load.
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§

default 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>,

§

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>,

§

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.