detect_interface_changes/
detect_interface_changes.rs

1//! Interface change notifier example.
2
3#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "illumos")))]
4fn main() {
5    let mut if_change_notifier = if_addrs::IfChangeNotifier::new().unwrap();
6    println!("Waiting for interface changes...");
7    loop {
8        if let Ok(details) = if_change_notifier.wait(None) {
9            println!("Network interfaces changed: {:#?}", details);
10        }
11    }
12}
13
14#[cfg(any(target_os = "macos", target_os = "ios", target_os = "illumos"))]
15fn main() {
16    panic!("Interface change API is not implemented for macOS or iOS");
17}