pub struct ConfigLock { /* private fields */ }
Expand description
A guard that holds the global configuration lock and provides override functionality.
This struct acts as both a lock guard (preventing other tests from modifying global config) and as the only way to create configuration overrides. Override guards cannot outlive this ConfigLock, ensuring proper synchronization.
Implementations§
Source§impl ConfigLock
impl ConfigLock
Sourcepub fn override_key<'a, T: AttrValue>(
&'a self,
key: Key<T>,
value: T,
) -> ConfigValueGuard<'a, T>
pub fn override_key<'a, T: AttrValue>( &'a self, key: Key<T>, value: T, ) -> ConfigValueGuard<'a, T>
Create a configuration override that will be restored when the guard is dropped.
The returned guard must not outlive this ConfigLock.
Trait Implementations§
Source§impl Drop for ConfigLock
When a ConfigLock
is dropped, the special
Source::TestOverride
layer (if present) is removed
entirely. This discards all temporary overrides created under
the lock, ensuring they cannot leak into subsequent tests or
callers. Other layers (Runtime
, Env
, File
, and defaults)
are left untouched.
impl Drop for ConfigLock
When a ConfigLock
is dropped, the special
Source::TestOverride
layer (if present) is removed
entirely. This discards all temporary overrides created under
the lock, ensuring they cannot leak into subsequent tests or
callers. Other layers (Runtime
, Env
, File
, and defaults)
are left untouched.
Note: individual values within the TestOverride layer may
already have been restored by ConfigValueGuard
s as they
drop. This final removal guarantees no residual layer remains
once the lock itself is released.
Auto Trait Implementations§
impl Freeze for ConfigLock
impl RefUnwindSafe for ConfigLock
impl !Send for ConfigLock
impl Sync for ConfigLock
impl Unpin for ConfigLock
impl UnwindSafe for ConfigLock
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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 more