[][src]Struct async_injector::Injector

pub struct Injector { /* fields omitted */ }

Use for handling injection.

Methods

impl Injector[src]

pub fn new() -> Self[src]

Create a new injector instance.

pub fn child(&self) -> Injector[src]

Construct a new child injector.

When a child injector is dropped, all associated listeners are cleaned up as well.

pub async fn clear<'_, T>(&'_ self) where
    T: Clone + Any + Send + Sync + 'static, 
[src]

Clear the given value.

pub async fn clear_key<'_, T>(&'_ self, key: impl AsRef<Key<T>>) where
    T: Clone + Any + Send + Sync + 'static, 
[src]

Clear the given value.

pub async fn update<'_, T>(&'_ self, value: T) where
    T: Any + Send + Sync + 'static + Clone
[src]

Set the given value and notify any subscribers.

pub async fn update_key<'_, T>(&'_ self, key: impl AsRef<Key<T>>, value: T) where
    T: Any + Send + Sync + 'static + Clone
[src]

Set the given value and notify any subscribers.

pub async fn get<'_, T>(&'_ self) -> Option<T> where
    T: Any + Send + Sync + 'static + Clone
[src]

Get a value from the injector.

pub async fn get_key<'_, T>(&'_ self, key: impl AsRef<Key<T>>) -> Option<T> where
    T: Any + Send + Sync + 'static + Clone
[src]

Get a value from the injector with the given key.

pub async fn stream<'_, T>(&'_ self) -> (Stream<T>, Option<T>) where
    T: Any + Send + Sync + 'static + Clone
[src]

Get an existing value and setup a stream for updates at the same time.

pub async fn stream_key<'_, T>(
    &'_ self,
    key: impl AsRef<Key<T>>
) -> (Stream<T>, Option<T>) where
    T: Any + Send + Sync + 'static + Clone
[src]

Get an existing value and setup a stream for updates at the same time.

pub async fn var<'_, T>(&'_ self) -> Result<Var<Option<T>>, Error> where
    T: Any + Send + Sync + 'static + Clone + Unpin
[src]

Get a synchronized variable for the given configuration key.

pub async fn var_key<'_, T>(
    &'_ self,
    key: impl AsRef<Key<T>>
) -> Result<Var<Option<T>>, Error> where
    T: Any + Send + Sync + 'static + Clone + Unpin
[src]

Get a synchronized variable for the given configuration key.

pub async fn drive(self) -> Result<(), Error>[src]

Run the injector as a future, making sure all asynchronous processes associated with it are driven to completion.

This has to be called for the injector to perform important tasks.

Trait Implementations

impl Clone for Injector[src]

impl Default for Injector[src]

Auto Trait Implementations

impl !RefUnwindSafe for Injector

impl Send for Injector

impl Sync for Injector

impl Unpin for Injector

impl !UnwindSafe for Injector

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.