[][src]Struct icee_container_rs::Container

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

Container for storing specific services

Stores all services of the same type (trait, int, ...) into an HashMap container wrapped within async Arc

Implementations

impl<T> Container<T>[src]

pub fn new() -> Self[src]

Creates a new Container

use icee_container_rs::Container;

let mut container = Container::<usize>::new();

pub fn has(&self, name: &str) -> bool[src]

Checks whether or not a given field is registered

use icee_container_rs::Container;

let container = Container::<usize>::new();
let exists = container.has("echo");

pub fn get(&self, name: &str) -> Result<Arc<T>, Error>[src]

Receives stored field from container

use icee_container_rs::Container;

let container = Container::<usize>::new();
let value = container.get("echo");

pub fn set(&mut self, name: &str, service: T) -> Arc<T>[src]

Stores service into container and returns pointer

use icee_container_rs::Container;
use async_std::sync::Arc;

let mut container = Container::<usize>::new();
let srv: Arc<usize> = container.set("echo", 666);

pub fn list(&self) -> Vec<String>[src]

List all available registered services

use icee_container_rs::Container;

let container = Container::<usize>::new();
let names = container.list();

Trait Implementations

impl<T> Default for Container<T>[src]

Auto Trait Implementations

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

impl<T> Send for Container<T> where
    T: Send + Sync
[src]

impl<T> Sync for Container<T> where
    T: Send + Sync
[src]

impl<T> Unpin for Container<T>[src]

impl<T> UnwindSafe for Container<T> where
    T: RefUnwindSafe
[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> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<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.