Struct runtime_injector::Arg[][src]

pub struct Arg<T: Service + AsAny + Clone>(_);
Expand description

Allows custom pre-defined values to be passed as arguments to services.

Example

use runtime_injector::{Arg, Injector, IntoTransient, WithArg};

struct Foo(Arg<i32>);

let mut builder = Injector::builder();
builder.provide(Foo.transient());
builder.with_arg::<Foo, i32>(12);

let injector = builder.build();
let foo: Box<Foo> = injector.get().unwrap();
assert_eq!(12, *foo.0);

Implementations

impl<T: Service + AsAny + Clone> Arg<T>[src]

pub fn into_inner(arg: Self) -> T[src]

Converts an argument into its inner value.

Trait Implementations

impl<T: Service + AsAny + Clone> Deref for Arg<T>[src]

type Target = T

The resulting type after dereferencing.

fn deref(&self) -> &Self::Target[src]

Dereferences the value.

impl<T: Service + AsAny + Clone> DerefMut for Arg<T>[src]

fn deref_mut(&mut self) -> &mut Self::Target[src]

Mutably dereferences the value.

impl<T: Service + AsAny + Clone> Request for Arg<T>[src]

Allows custom pre-defined values to be passed as arguments to services.

fn request(_injector: &Injector, info: &RequestInfo) -> InjectResult<Self>[src]

Performs the request to the injector.

Auto Trait Implementations

impl<T> RefUnwindSafe for Arg<T> where
    T: RefUnwindSafe

impl<T> Send for Arg<T>

impl<T> Sync for Arg<T>

impl<T> Unpin for Arg<T> where
    T: Unpin

impl<T> UnwindSafe for Arg<T> where
    T: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.