File: detect_interface_changes.rs

package info (click to toggle)
rust-if-addrs 0.13.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: makefile: 4
file content (17 lines) | stat: -rw-r--r-- 533 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Interface change notifier example.

#[cfg(not(any(target_os = "macos", target_os = "ios")))]
fn main() {
    let mut if_change_notifier = if_addrs::IfChangeNotifier::new().unwrap();
    println!("Waiting for interface changes...");
    loop {
        if let Ok(details) = if_change_notifier.wait(None) {
            println!("Network interfaces changed: {:#?}", details);
        }
    }
}

#[cfg(any(target_os = "macos", target_os = "ios"))]
fn main() {
    panic!("Interface change API is not implemented for macOS or iOS");
}