-pub fn watch_interfaces<F: FnMut(Update)>(callback: F) -> WatchHandle {
- // stop current worker thread
- // post this into a thread that will use it
- drop(callback);
- WatchHandle
+/// Retrieve interface information and watch for changes, which will be delivered via callback.
+///
+/// If setting up the watch is successful, this returns a `WatchHandle` which must be kept for
+/// as long as the provided callback should operate.
+///
+/// The callback will fire once immediately with an initial interface list, and a diff as if
+/// there were originally no interfaces present.
+///
+/// This function will return an error if there is a problem configuring the watcher, or if there
+/// is an error retrieving the initial interface list.
+///
+/// We assume that if listing the interfaces worked the first time, then it will continue to work
+/// for as long as the watcher is running. If listing interfaces begins to fail later, those
+/// failures will be swallowed and the callback will not be called for that change event.
+pub fn watch_interfaces<F: FnMut(Update) + Send + 'static>(
+ callback: F,
+) -> Result<WatchHandle, Error> {
+ watch::watch_interfaces(callback).map(|handle| WatchHandle { _inner: handle })