pub struct DependencyScopeError {
pub request_scoped_type: String,
pub function_scoped_type: String,
}Expand description
Error returned when a dependency scope constraint is violated.
This occurs when a request-scoped dependency depends on a function-scoped dependency. Since request-scoped dependencies are cached for the lifetime of the request, they would hold stale values from function-scoped dependencies (which should be resolved fresh on each call).
§Example
Dependency scope violation: request-scoped 'CachedUser' depends on
function-scoped 'DbConnection'. Request-scoped dependencies cannot
depend on function-scoped dependencies because the cached value
would become stale.§Why This Matters
Consider this scenario:
CachedUseris request-scoped (cached for the request)DbConnectionis function-scoped (fresh connection each call)
If CachedUser depends on DbConnection:
- First request:
CachedUserresolved, cachesDbConnectionvalue - Later in same request:
CachedUserretrieved from cache - Problem: The cached
CachedUserholds a staleDbConnection
This violates the contract that function-scoped dependencies are fresh.
Fields§
§request_scoped_type: StringThe name of the request-scoped dependency (the outer one).
function_scoped_type: StringThe name of the function-scoped dependency (the inner one).
Implementations§
Trait Implementations§
Source§impl Clone for DependencyScopeError
impl Clone for DependencyScopeError
Source§fn clone(&self) -> DependencyScopeError
fn clone(&self) -> DependencyScopeError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DependencyScopeError
impl Debug for DependencyScopeError
Source§impl Display for DependencyScopeError
impl Display for DependencyScopeError
Source§impl Error for DependencyScopeError
impl Error for DependencyScopeError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl IntoResponse for DependencyScopeError
impl IntoResponse for DependencyScopeError
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Convert into a response.
Auto Trait Implementations§
impl Freeze for DependencyScopeError
impl RefUnwindSafe for DependencyScopeError
impl Send for DependencyScopeError
impl Sync for DependencyScopeError
impl Unpin for DependencyScopeError
impl UnwindSafe for DependencyScopeError
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).