[][src]Struct async_injector::Key

pub struct Key<T> where
    T: Any
{ /* fields omitted */ }

A key used to discriminate a value in the Injector.

Implementations

impl<T> Key<T> where
    T: Any
[src]

pub fn of() -> Self[src]

Construct a new key without a tag.

Examples

use async_injector::Key;

struct Foo;

assert_eq!(Key::<Foo>::of(), Key::<Foo>::of());

pub fn tagged<K>(tag: K) -> Result<Self, Error> where
    K: Any + Serialize
[src]

Construct a new key.

Examples

use serde::Serialize;
use async_injector::Key;
use std::error::Error;

struct Foo;

#[derive(Serialize)]
enum Tag {
    One,
    Two,
}

#[derive(Serialize)]
enum Tag2 {
    One,
    Two,
}

assert_eq!(Key::<Foo>::tagged(Tag::One)?, Key::<Foo>::tagged(Tag::One)?);
assert_ne!(Key::<Foo>::tagged(Tag::One)?, Key::<Foo>::tagged(Tag::Two)?);
assert_ne!(Key::<Foo>::tagged(Tag::One)?, Key::<Foo>::tagged(Tag2::One)?);

Trait Implementations

impl<T> AsRef<Key<T>> for Key<T> where
    T: 'static, 
[src]

impl<T: Clone> Clone for Key<T> where
    T: Any
[src]

impl<T> Debug for Key<T> where
    T: Any
[src]

impl<T> Eq for Key<T> where
    T: Any
[src]

impl<T> Hash for Key<T> where
    T: Any
[src]

impl<T> Ord for Key<T> where
    T: Any
[src]

impl<T> PartialEq<Key<T>> for Key<T> where
    T: Any
[src]

impl<T> PartialOrd<Key<T>> for Key<T> where
    T: Any
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Key<T> where
    T: RefUnwindSafe
[src]

impl<T> Send for Key<T> where
    T: Send
[src]

impl<T> Sync for Key<T> where
    T: Sync
[src]

impl<T> Unpin for Key<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Key<T> where
    T: UnwindSafe
[src]

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> CallHasher for T where
    T: Hash

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.