]>
code.octet-stream.net Git - netwatcher/blob - src/watch_mac.rs
3 // The "objc2" project aims to provide bindings for all frameworks but Network.framework
4 // isn't ready yet so let's kick it old-school
6 struct nw_path_monitor
;
7 type nw_path_monitor_t
= *mut nw_path_monitor
;
9 type nw_path_t
= *mut nw_path
;
10 struct dispatch_queue
;
11 type dispatch_queue_t
= *mut dispatch_queue
;
12 const QOS_CLASS_BACKGROUND
: usize = 0x09;
14 #[link(name = "Network", kind = "framework")]
16 fn nw_path_monitor_create() -> nw_path_monitor_t
;
17 fn nw_path_monitor_set_update_handler(
18 monitor
: nw_path_monitor_t
,
19 update_handler
: &Block
<dyn
Fn(nw_path_t
)>,
21 fn nw_path_monitor_set_queue(monitor
: nw_path_monitor_t
, queue
: dispatch_queue_t
);
22 fn nw_path_monitor_start(monitor
: nw_path_monitor_t
);
23 fn nw_path_monitor_cancel(monitor
: nw_path_monitor_t
);
25 fn dispatch_get_global_queue(identifier
: usize, flag
: usize) -> dispatch_queue_t
;
30 use super::list_interfaces
;
34 let ifaces
= list_interfaces().unwrap
();
35 println
!("{:?}", ifaces
);
39 pub(crate) struct WatchHandle
;
41 pub(crate) fn watch_interfaces
<F
: FnMut(Update
) + '
static>(
43 ) -> Result
<WatchHandle
, Error
> {
44 // stop current worker thread
45 // post this into a thread that will use it