pub enum DependencyScope {
Singleton,
Request,
Transient,
}Expand description
Scope for dependency injection
Variants§
Singleton
Single instance shared across the entire application
Request
New instance per request, cached within the request
Transient
New instance every time, never cached
Implementations§
Source§impl DependencyScope
impl DependencyScope
Sourcepub fn outlives(&self, dependent: DependencyScope) -> bool
pub fn outlives(&self, dependent: DependencyScope) -> bool
Returns true if a type at scope self (the dependency being resolved)
lives at least as long as a type at scope dependent (the type
requesting resolution).
The only prohibited combination is a Singleton-scoped dependent
resolving a Request-scoped dependency, because the singleton would
capture a stale, request-bound value for the entire process lifetime.
Trait Implementations§
Source§impl Clone for DependencyScope
impl Clone for DependencyScope
Source§fn clone(&self) -> DependencyScope
fn clone(&self) -> DependencyScope
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for DependencyScope
Source§impl Debug for DependencyScope
impl Debug for DependencyScope
Source§impl Default for DependencyScope
impl Default for DependencyScope
Source§fn default() -> DependencyScope
fn default() -> DependencyScope
Returns the “default value” for a type. Read more
impl Eq for DependencyScope
Source§impl PartialEq for DependencyScope
impl PartialEq for DependencyScope
Source§fn eq(&self, other: &DependencyScope) -> bool
fn eq(&self, other: &DependencyScope) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DependencyScope
Auto Trait Implementations§
impl Freeze for DependencyScope
impl RefUnwindSafe for DependencyScope
impl Send for DependencyScope
impl Sync for DependencyScope
impl Unpin for DependencyScope
impl UnsafeUnpin for DependencyScope
impl UnwindSafe for DependencyScope
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
impl<E> ServerFnErrorAssertions<E> for Ewhere
E: Debug,
Source§fn should_contain_message(&self, expected: &str)where
E: Display,
fn should_contain_message(&self, expected: &str)where
E: Display,
Assert that the error message contains the specified text.
Source§fn should_have_message(&self, expected: &str)where
E: Display,
fn should_have_message(&self, expected: &str)where
E: Display,
Assert that the error message matches exactly.