Trait runtime_injector_actix::IntoTransient [−][src]
pub trait IntoTransient<D, R, F> where
R: Service,
F: ServiceFactory<D, Result = R>, { #[must_use] fn transient(self) -> TransientProvider<D, R, F>; }
Expand description
Defines a conversion into a transient provider. This trait is automatically implemented for all service factories.
Required methods
#[must_use]fn transient(self) -> TransientProvider<D, R, F>
[src]
#[must_use]
fn transient(self) -> TransientProvider<D, R, F>Expand description
Creates a transient provider. Transient providers create their values each time the service is requested and will never return service pointers to the same instance more than once.
Example
use runtime_injector::{Injector, IntoTransient, Svc}; #[derive(Default)] struct Foo; let mut builder = Injector::builder(); builder.provide(Foo::default.transient()); let injector = builder.build(); let foo1: Svc<Foo> = injector.get().unwrap(); let foo2: Svc<Foo> = injector.get().unwrap(); assert!(!Svc::ptr_eq(&foo1, &foo2));
Implementors
impl<D, R, F> IntoTransient<D, R, F> for F where
R: Service,
F: ServiceFactory<D, Result = R>,
[src]
impl<D, R, F> IntoTransient<D, R, F> for F where
R: Service,
F: ServiceFactory<D, Result = R>,
[src]