pub trait DynAccess<T> {
    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

extern crate arc_swap;

use std::thread;

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

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

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

Required Methods§

The equivalent of Access::load.

Implementors§