jay_config/macros.rs
1/// Declares the entry point of the configuration.
2#[macro_export]
3macro_rules! config {
4 ($f:path) => {
5 #[unsafe(no_mangle)]
6 #[used]
7 pub static mut JAY_CONFIG_ENTRY_V1: $crate::_private::ConfigEntry = {
8 struct X;
9 impl $crate::_private::Config for X {
10 extern "C" fn configure() {
11 $f();
12 }
13 }
14 $crate::_private::ConfigEntryGen::<X>::ENTRY
15 };
16 };
17}
18
19macro_rules! try_get {
20 () => {{
21 unsafe {
22 let client = crate::_private::client::CLIENT.with(|client| client.get());
23 if client.is_null() {
24 None
25 } else {
26 Some(&*client)
27 }
28 }
29 }};
30}
31
32macro_rules! get {
33 () => {{
34 get!(Default::default())
35 }};
36 ($def:expr) => {{
37 let client = unsafe {
38 let client = crate::_private::client::CLIENT.with(|client| client.get());
39 if client.is_null() {
40 return $def;
41 }
42 &*client
43 };
44 client
45 }};
46}
47
48// #[macro_export]
49// macro_rules! log {
50// ($lvl:expr, $($arg:tt)+) => ({
51// $crate::log(
52// $lvl,
53// &format!($($args)*),
54// );
55// })
56// }
57//
58// #[macro_export]
59// macro_rules! trace {
60// ($($arg:tt)+) => {
61// $crate::log!($crate::LogLevel::Trace, $($arg)+)
62// }
63// }
64//
65// #[macro_export]
66// macro_rules! debug {
67// ($($arg:tt)+) => {
68// $crate::log!($crate::LogLevel::Debug, $($arg)+)
69// }
70// }
71//
72// #[macro_export]
73// macro_rules! info {
74// ($($arg:tt)+) => {
75// $crate::log!($crate::LogLevel::Info, $($arg)+)
76// }
77// }
78//
79// #[macro_export]
80// macro_rules! info {
81// ($($arg:tt)+) => {
82// $crate::log!($crate::LogLevel::Info, $($arg)+)
83// }
84// }