pub struct ContextGuard { /* private fields */ }Available on crate feature
std only.Expand description
RAII guard that removes a context entry when dropped.
Returned by with_field, with_trace_id, with_request_id
and ContextSnapshot::attach. Guards may be dropped in any order.
The guard is deliberately !Send and !Sync: context lives in the
thread that created the guard, so the guard must be dropped there.
Holding one across an .await makes the future !Send. Use
ContextSnapshot to carry context into other threads or tasks.
ⓘ
let guard = log_io::context::with_field("tenant", "a");
std::thread::spawn(move || drop(guard)); // error: `ContextGuard` is not `Send`Trait Implementations§
Source§impl Debug for ContextGuard
impl Debug for ContextGuard
Source§impl Drop for ContextGuard
impl Drop for ContextGuard
Auto Trait Implementations§
impl !Send for ContextGuard
impl !Sync for ContextGuard
impl Forget for ContextGuard
impl Freeze for ContextGuard
impl Move for ContextGuard
impl RefUnwindSafe for ContextGuard
impl Unpin for ContextGuard
impl UnsafeUnpin for ContextGuard
impl UnwindSafe for ContextGuard
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