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§
sourcefn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
The equivalent of Access::load
.