1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Attach guards for swapping entire context stores.
//!
//! Unlike `ScopeGuard` (which pushes/pops a scope within the current store),
//! `AttachGuard` replaces the entire thread-local store and restores it on drop.
use crateContextStore;
use crateCONTEXT;
/// RAII guard that restores the previous thread-local store on drop.
///
/// Created by [`attach_snapshot`](crate::attach_snapshot) or
/// [`attach_store`](crate::attach_store).
///
/// # `!Send` constraint
///
/// This guard is `!Send` — it **must** be dropped on the same thread where it was created.
/// Holding it across `.await` in a multi-threaded runtime will cause a compile error.
///
/// For async code, use `.attach(snap)` or `.scope("name")` from [`ContextFutureExt`](crate::ContextFutureExt)
/// instead of manually creating guards.