1use std::collections::HashMap;
2#[cfg(target_os = "windows")]
3use windows::core::Error;
4#[cfg(target_os = "windows")]
5use windows::Devices::Bluetooth::GenericAttributeProfile::GattCharacteristic;
6use crate::device::{Characteristic, Device};
7
8
9#[cfg(target_os = "macos")]
10pub mod mac;
11#[cfg(target_os = "windows")]
12pub mod win;
13pub mod device;
14pub fn run<F>(factory: F)
15where
16 F: Fn() -> Box<dyn Handler>,
17{
18 #[cfg(target_os = "windows")]
19 win::Win::new().run(factory);
20 #[cfg(target_os = "macos")]
21 mac::Mac::new().run(factory);
22}
23
24
25pub trait Handler {
26 fn on_adapter_open(&mut self);
28 fn on_adapter_close(&mut self);
30 fn on_discover(&mut self, device: Device);
32 fn get_device_list(&mut self) ->HashMap<String,Device>;
34 fn on_connect(&mut self, uuid: String);
36 fn on_unconnect(&mut self, uuid: String);
38 fn on_disconnect(&mut self, uuid: String);
41 fn on_characteristics(&mut self, uuid: String, characteristic: Characteristic);
43 fn listen(&mut self, uuid: String);
45
46 fn on_data(&mut self, uuid: String, characteristic_uuid: String, data: Vec<u8>);
48}