1use json::JsonValue;
2use crate::device::{Characteristic, Device};
3
4pub mod device;
5#[cfg(target_os = "macos")]
6pub mod mac;
7#[cfg(target_os = "windows")]
8pub mod win;
9pub fn run<F>(factory: F)
10where
11 F: Fn() -> Box<dyn Handler>,
12{
13 #[cfg(target_os = "windows")]
14 win::Win::new().run(factory);
15 #[cfg(target_os = "macos")]
16 mac::Mac::new().run(factory);
17}
18
19pub trait Handler {
20 fn on_adapter_open(&mut self);
22 fn on_adapter_close(&mut self);
24 fn on_discover(&mut self, device: Device);
26 fn listen_connected(&mut self, device_list: Vec<String>);
28 fn on_connect(&mut self, uuid: String);
30 fn on_unconnect(&mut self, uuid: String);
32 fn on_disconnect(&mut self, uuid: String);
35 fn on_characteristics(&mut self, uuid: String, characteristic: Characteristic);
37 fn listen(&mut self, uuid: String);
39
40 fn on_data(&mut self, uuid: String, characteristic_uuid: String, data: Vec<u8>);
42}