]> code.octet-stream.net Git - netwatcher/blobdiff - examples/watch.rs
Switch to simpler MIT licence
[netwatcher] / examples / watch.rs
index 4129dc668a520d3512698af9306eb83f475cbb37..767fd19ee72d7fe1fa2e848f722c1579ca8b0112 100644 (file)
@@ -1,13 +1,18 @@
 use std::time::Duration;
 
 fn main() {
 use std::time::Duration;
 
 fn main() {
-    let _handle = netwatcher::watch_interfaces(|update| {
+    println!("Watching for changes for 30 seconds...");
+
+    let handle = netwatcher::watch_interfaces(|update| {
         println!("Interface update!");
         println!("Interface update!");
-        println!("State: {:?}", update.interfaces);
-        println!("Diff: {:?}", update.diff);
+        println!("State: {:#?}", update.interfaces);
+        println!("Diff: {:#?}", update.diff);
     });
 
     });
 
-    loop {
-        std::thread::sleep(Duration::from_secs(60));
-    }
+    std::thread::sleep(Duration::from_secs(30));
+
+    drop(handle);
+    println!("Stopped watching! Program will end in 30 seconds.");
+
+    std::thread::sleep(Duration::from_secs(30));
 }
 }