Struct if_addrs::IfChangeNotifier
source · pub struct IfChangeNotifier { /* private fields */ }
Expand description
(Not available on iOS/macOS) A utility to monitor for interface changes and report them, so you can handle events such as WiFi disconnection/flight mode/route changes
Implementations§
source§impl IfChangeNotifier
impl IfChangeNotifier
sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new interface change notifier. Returns an OS specific error if the network notifier could not be set up.
sourcepub fn wait(&mut self, timeout: Option<Duration>) -> Result<Vec<IfChangeType>>
pub fn wait(&mut self, timeout: Option<Duration>) -> Result<Vec<IfChangeType>>
(Not available on iOS/macOS) Block until the OS reports that the network interface list has changed, or until an optional timeout.
For example, if an ethernet connector is plugged/unplugged, or a WiFi network is connected to.
The changed interfaces are returned. If an interface has both IPv4
and IPv6 addresses, you can expect both of them to be returned from
a single call to wait
.
Returns an [io::ErrorKind::WouldBlock
] error on timeout, or
another error if the network notifier could not be read from.