]> code.octet-stream.net Git - netwatcher/blobdiff - src/watch_mac.rs
Make example program test dropping the WatchHandle
[netwatcher] / src / watch_mac.rs
index de0e65024c27c8b912832a4775f7ac7413d38833..c44169cf25a28b9fc937ecafd3865bc2e76bba35 100644 (file)
@@ -22,6 +22,8 @@ unsafe impl objc2::Encode for NwPath {
     const ENCODING: Encoding = usize::ENCODING;
 }
 
+unsafe impl Send for WatchHandle {}
+
 #[link(name = "Network", kind = "framework")]
 extern "C" {
     fn nw_path_monitor_create() -> NwPathMonitorT;
@@ -42,7 +44,9 @@ pub(crate) struct WatchHandle {
 
 impl Drop for WatchHandle {
     fn drop(&mut self) {
-        unsafe { nw_path_monitor_cancel(self.path_monitor); }
+        unsafe {
+            nw_path_monitor_cancel(self.path_monitor);
+        }
     }
 }
 
@@ -83,7 +87,5 @@ pub(crate) fn watch_interfaces<F: FnMut(Update) + Send + 'static>(
         nw_path_monitor_set_queue(path_monitor, queue);
         nw_path_monitor_start(path_monitor);
     }
-    Ok(WatchHandle {
-        path_monitor,
-    })
+    Ok(WatchHandle { path_monitor })
 }