Struct arc_swap::access::Map

source ·
pub struct Map<A, T, F> { /* private fields */ }
Expand description

An adaptor to provide access to a part of larger structure.

This is the active part of this module. Use the module documentation for the details.

Implementations§

source§

impl<A, T, F> Map<A, T, F>

source

pub fn new<R>(access: A, projection: F) -> Self
where F: Fn(&T) -> &R + Clone,

Creates a new instance.

§Parameters
  • access: Access to the bigger structure. This is usually something like Arc<ArcSwap> or &ArcSwap. It is technically possible to use any other Access here, though, for example to sub-delegate into even smaller structure from a Map (or generic Access).
  • projection: A function (or closure) responsible to providing a reference into the bigger bigger structure, selecting just subset of it. In general, it is expected to be cheap (like only taking reference).

Trait Implementations§

source§

impl<A, F, T, R> Access<R> for Map<A, T, F>
where A: Access<T>, F: Fn(&T) -> &R + Clone,

§

type Guard = MapGuard<<A as Access<T>>::Guard, F, T, R>

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<A: Clone, T: Clone, F: Clone> Clone for Map<A, T, F>

source§

fn clone(&self) -> Map<A, T, F>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<A: Debug, T: Debug, F: Debug> Debug for Map<A, T, F>

source§

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

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

impl<A: Copy, T: Copy, F: Copy> Copy for Map<A, T, F>

Auto Trait Implementations§

§

impl<A, T, F> Freeze for Map<A, T, F>
where A: Freeze, F: Freeze,

§

impl<A, T, F> RefUnwindSafe for Map<A, T, F>

§

impl<A, T, F> Send for Map<A, T, F>
where A: Send, F: Send,

§

impl<A, T, F> Sync for Map<A, T, F>
where A: Sync, F: Sync,

§

impl<A, T, F> Unpin for Map<A, T, F>
where A: Unpin, F: Unpin,

§

impl<A, T, F> UnwindSafe for Map<A, T, F>
where A: UnwindSafe, F: UnwindSafe,

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, 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.