1use super::{fallback, primary};
2use std::boxed::Box;
3
4#[cfg(feature = "global")]
5use crate::{GlobalDynFallibleTryDropStrategy, GlobalTryDropStrategy};
6
7#[cfg(feature = "thread-local")]
8use crate::{ThreadLocalFallibleTryDropStrategy, ThreadLocalTryDropStrategy};
9
10#[cfg(feature = "global")]
12pub fn install_global_handlers(
13 primary: impl GlobalDynFallibleTryDropStrategy,
14 fallback: impl GlobalTryDropStrategy,
15) {
16 install_global_handlers_dyn(Box::new(primary), Box::new(fallback))
17}
18
19#[cfg(feature = "global")]
21pub fn install_global_handlers_dyn(
22 primary: Box<dyn GlobalDynFallibleTryDropStrategy>,
23 fallback: Box<dyn GlobalTryDropStrategy>,
24) {
25 primary::global::install_dyn(primary);
26 fallback::global::install_dyn(fallback);
27}
28
29#[cfg(feature = "global")]
31pub fn uninstall_globally() {
32 primary::global::uninstall();
33 fallback::global::uninstall();
34}
35
36#[cfg(feature = "thread-local")]
38pub fn install_thread_local_handlers(
39 primary: impl ThreadLocalFallibleTryDropStrategy,
40 fallback: impl ThreadLocalTryDropStrategy,
41) {
42 install_thread_local_handlers_dyn(Box::new(primary), Box::new(fallback))
43}
44
45#[cfg(feature = "thread-local")]
48pub fn install_thread_local_handlers_dyn(
49 primary: Box<dyn ThreadLocalFallibleTryDropStrategy>,
50 fallback: Box<dyn ThreadLocalTryDropStrategy>,
51) {
52 primary::thread_local::install_dyn(primary);
53 fallback::thread_local::install_dyn(fallback);
54}
55
56#[cfg(feature = "thread-local")]
58pub fn install_thread_local_handlers_for_this_scope(
59 primary: impl ThreadLocalFallibleTryDropStrategy,
60 fallback: impl ThreadLocalTryDropStrategy,
61) -> (
62 primary::thread_local::ScopeGuard,
63 fallback::thread_local::ScopeGuard,
64) {
65 install_thread_local_handlers_for_this_scope_dyn(Box::new(primary), Box::new(fallback))
66}
67
68#[cfg(feature = "thread-local")]
71pub fn install_thread_local_handlers_for_this_scope_dyn(
72 primary: Box<dyn ThreadLocalFallibleTryDropStrategy>,
73 fallback: Box<dyn ThreadLocalTryDropStrategy>,
74) -> (
75 primary::thread_local::ScopeGuard,
76 fallback::thread_local::ScopeGuard,
77) {
78 (
79 primary::thread_local::scope_dyn(primary),
80 fallback::thread_local::scope_dyn(fallback),
81 )
82}
83
84#[cfg(feature = "thread-local")]
86pub fn uninstall_for_thread() {
87 primary::thread_local::uninstall();
88 fallback::thread_local::uninstall();
89}