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