[][src]Struct async_injector::Var

pub struct Var<T> { /* fields omitted */ }

Proxy accessor for an injected variable.

This stores a reference to the given variable and provides methods for accessing it, similarly to an RwLock, but biased towards efficient cloning.

Implementations

impl<T> Var<T>[src]

pub fn new(value: T) -> Self[src]

Construct a new variable holder.

impl<T> Var<T> where
    T: Clone
[src]

pub async fn load<'_>(&'_ self) -> T[src]

Load the given variable, cloning the underlying value while doing so.

impl<T> Var<T>[src]

pub async fn read<'_, '_>(&'_ self) -> RwLockReadGuard<'_, T>[src]

Read referentially from the underlying variable.

pub async fn write<'_, '_>(&'_ self) -> RwLockWriteGuard<'_, T>[src]

Write to the underlying variable.

Trait Implementations

impl<T> Clone for Var<T>[src]

impl<T: Debug> Debug for Var<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Var<T>

impl<T> Send for Var<T> where
    T: Send + Sync

impl<T> Sync for Var<T> where
    T: Send + Sync

impl<T> Unpin for Var<T>

impl<T> !UnwindSafe for Var<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.