[][src]Struct kamikaze_di::Container

pub struct Container { /* fields omitted */ }

Dependency container. Can be used with Resolver or Injector.

See Injector and Resolver on how to use. Use the ContainerBuilder to set up containers.

Methods

impl Container[src]

pub fn new() -> Container[src]

Creates an empty container.

Even though it will be empty, it will still resolve dependencies via the Injector trait.

Examples

use kamikaze_di::{Container, Inject, Injector, Result};

#[derive(Clone)]
struct X {
    inner: usize,
};

impl Inject for X {
    fn resolve(container: &Container) -> Result<X> {
        Ok(X { inner: 42 })
    }
}

let container: Container = Container::new();
let x: X = container.inject()?;

assert_eq!(42, x.inner);

Trait Implementations

impl<T> Injector<T> for Container where
    T: Clone + 'static, 
[src]

impl<T> Injector<T> for Container where
    T: Inject + Clone + 'static, 
[src]

impl<T> Injector<Rc<T>> for Container where
    T: InjectAsRc + 'static, 
[src]

impl Resolver for Container[src]

impl Default for Container[src]

impl Debug for Container[src]

Auto Trait Implementations

impl !Send for Container

impl !Sync for Container

Blanket Implementations

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

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

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.

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

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

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