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