servo_bluetooth/
macros.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#[cfg(feature = "bluetooth-test")]
6macro_rules! get_inner_and_call_test_func {
7    ($enum_value: expr, $enum_type: ident, $function_name: ident, $value: expr) => {
8        match $enum_value {
9            &$enum_type::Mock(ref fake) => fake.$function_name($value),
10            #[cfg(feature = "native-bluetooth")]
11            _ => Err(Box::from(
12                "Error! Test functions are not supported on real devices!",
13            )),
14        }
15    };
16
17    ($enum_value: expr, $enum_type: ident, $function_name: ident) => {
18        match $enum_value {
19            &$enum_type::Mock(ref fake) => fake.$function_name(),
20            #[cfg(feature = "native-bluetooth")]
21            _ => Err(Box::from(
22                "Error! Test functions are not supported on real devices!",
23            )),
24        }
25    };
26}
27
28#[cfg(feature = "bluetooth-test")]
29pub(crate) use get_inner_and_call_test_func;