Trait arc_swap::access::DynAccess

source ·
pub trait DynAccess<T> {
    // Required method
    fn load(&self) -> DynGuard<T>;
}
Expand description

An object-safe version of the Access trait.

This can be used instead of the Access trait in case a type erasure is desired. This has the effect of performance hit (due to boxing of the result and due to dynamic dispatch), but makes certain code simpler and possibly makes the executable smaller.

This is automatically implemented for everything that implements Access.

§Examples

use arc_swap::access::{Constant, DynAccess};

fn do_something(value: Box<dyn DynAccess<usize> + Send>) {
    let v = value.load();
    println!("{}", *v);
}

do_something(Box::new(Constant(42)));

Required Methods§

source

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

The equivalent of Access::load.

Trait Implementations§

source§

impl<T> Access<T> for dyn DynAccess<T> + '_

§

type Guard = DynGuard<T>

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

fn load(&self) -> Self::Guard

The loading method. Read more
source§

impl<T> Access<T> for dyn DynAccess<T> + Send + '_

§

type Guard = DynGuard<T>

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

fn load(&self) -> Self::Guard

The loading method. Read more
source§

impl<T> Access<T> for dyn DynAccess<T> + Sync + Send + '_

§

type Guard = DynGuard<T>

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

fn load(&self) -> Self::Guard

The loading method. Read more

Implementors§

source§

impl<T, A> DynAccess<T> for A
where A: Access<T>, A::Guard: 'static,