1 //! Utility modules and functions for facade services.
2 
3 pub mod converters {
4     use bt_topshim::btif::BluetoothProperty;
5     use bt_topshim_facade_protobuf::facade::EventData;
6 
bluetooth_property_to_event_data(property: BluetoothProperty) -> (String, EventData)7     pub fn bluetooth_property_to_event_data(property: BluetoothProperty) -> (String, EventData) {
8         match property {
9             BluetoothProperty::BdName(name) => {
10                 (String::from("BdName"), event_data_from_string(name))
11             }
12             BluetoothProperty::BdAddr(address) => {
13                 (String::from("BdAddr"), event_data_from_string(address.to_string()))
14             }
15             BluetoothProperty::Uuids(uuids) => {
16                 let mut event = EventData::new();
17                 for uuid in uuids {
18                     event.data.push(format!("{:?}", uuid));
19                 }
20                 (String::from("Uuids"), event)
21             }
22             BluetoothProperty::AdapterScanMode(mode) => {
23                 (String::from("AdapterScanMode"), event_data_from_string(format!("{:?}", mode)))
24             }
25             BluetoothProperty::LocalIoCaps(caps) => {
26                 (String::from("LocalIoCaps"), event_data_from_string(format!("{:?}", caps)))
27             }
28             _ => (String::from("skip"), EventData::new()),
29         }
30     }
31 
event_data_from_string(data: String) -> EventData32     pub fn event_data_from_string(data: String) -> EventData {
33         let mut event = EventData::new();
34         event.data.push(data);
35         event
36     }
37 }
38