1macro_rules! get_inner_and_call(
6 ($enum_value: expr, $enum_type: ident, $function_name: ident) => {
7 match $enum_value {
8 #[cfg(all(target_os = "linux", feature = "native-bluetooth"))]
9 &$enum_type::Bluez(ref bluez) => bluez.$function_name(),
10 #[cfg(all(target_os = "android", feature = "native-bluetooth"))]
11 &$enum_type::Android(ref android) => android.$function_name(),
12 #[cfg(all(target_os = "macos", feature = "native-bluetooth"))]
13 &$enum_type::Mac(ref mac) => mac.$function_name(),
14 #[cfg(not(any(all(target_os = "linux", feature = "native-bluetooth"),
15 all(target_os = "android", feature = "native-bluetooth"),
16 all(target_os = "macos", feature = "native-bluetooth"))))]
17 &$enum_type::Empty(ref empty) => empty.$function_name(),
18 #[cfg(feature = "bluetooth-test")]
19 &$enum_type::Mock(ref fake) => fake.$function_name(),
20 }
21 };
22
23 (@with_bluez_offset, $enum_value: expr, $enum_type: ident, $function_name: ident) => {
24 match $enum_value {
25 #[cfg(all(target_os = "linux", feature = "native-bluetooth"))]
26 &$enum_type::Bluez(ref bluez) => bluez.$function_name(None),
27 #[cfg(all(target_os = "android", feature = "native-bluetooth"))]
28 &$enum_type::Android(ref android) => android.$function_name(),
29 #[cfg(all(target_os = "macos", feature = "native-bluetooth"))]
30 &$enum_type::Mac(ref mac) => mac.$function_name(),
31 #[cfg(not(any(all(target_os = "linux", feature = "native-bluetooth"),
32 all(target_os = "android", feature = "native-bluetooth"),
33 all(target_os = "macos", feature = "native-bluetooth"))))]
34 &$enum_type::Empty(ref empty) => empty.$function_name(),
35 #[cfg(feature = "bluetooth-test")]
36 &$enum_type::Mock(ref fake) => fake.$function_name(),
37 }
38 };
39
40 ($enum_value: expr, $enum_type: ident, $function_name: ident, $value: expr) => {
41 match $enum_value {
42 #[cfg(all(target_os = "linux", feature = "native-bluetooth"))]
43 &$enum_type::Bluez(ref bluez) => bluez.$function_name($value),
44 #[cfg(all(target_os = "android", feature = "native-bluetooth"))]
45 &$enum_type::Android(ref android) => android.$function_name($value),
46 #[cfg(all(target_os = "macos", feature = "native-bluetooth"))]
47 &$enum_type::Mac(ref mac) => mac.$function_name($value),
48 #[cfg(not(any(all(target_os = "linux", feature = "native-bluetooth"),
49 all(target_os = "android", feature = "native-bluetooth"),
50 all(target_os = "macos", feature = "native-bluetooth"))))]
51 &$enum_type::Empty(ref empty) => empty.$function_name($value),
52 #[cfg(feature = "bluetooth-test")]
53 &$enum_type::Mock(ref fake) => fake.$function_name($value),
54 }
55 };
56
57 (@with_bluez_offset, $enum_value: expr, $enum_type: ident, $function_name: ident, $value: expr) => {
58 match $enum_value {
59 #[cfg(all(target_os = "linux", feature = "native-bluetooth"))]
60 &$enum_type::Bluez(ref bluez) => bluez.$function_name($value, None),
61 #[cfg(all(target_os = "android", feature = "native-bluetooth"))]
62 &$enum_type::Android(ref android) => android.$function_name($value),
63 #[cfg(all(target_os = "macos", feature = "native-bluetooth"))]
64 &$enum_type::Mac(ref mac) => mac.$function_name($value),
65 #[cfg(not(any(all(target_os = "linux", feature = "native-bluetooth"),
66 all(target_os = "android", feature = "native-bluetooth"),
67 all(target_os = "macos", feature = "native-bluetooth"))))]
68 &$enum_type::Empty(ref empty) => empty.$function_name($value),
69 #[cfg(feature = "bluetooth-test")]
70 &$enum_type::Mock(ref fake) => fake.$function_name($value),
71 }
72 };
73);
74
75#[cfg(feature = "bluetooth-test")]
76macro_rules! get_inner_and_call_test_func {
77 ($enum_value: expr, $enum_type: ident, $function_name: ident, $value: expr) => {
78 match $enum_value {
79 &$enum_type::Mock(ref fake) => fake.$function_name($value),
80 _ => Err(Box::from(
81 "Error! Test functions are not supported on real devices!",
82 )),
83 }
84 };
85
86 ($enum_value: expr, $enum_type: ident, $function_name: ident) => {
87 match $enum_value {
88 &$enum_type::Mock(ref fake) => fake.$function_name(),
89 _ => Err(Box::from(
90 "Error! Test functions are not supported on real devices!",
91 )),
92 }
93 };
94}
95
96pub(crate) use get_inner_and_call;
97#[cfg(feature = "bluetooth-test")]
98pub(crate) use get_inner_and_call_test_func;