pub struct WatcherHandle { /* private fields */ }Expand description
Owns the watcher background thread. Drop to stop watching.
notify-debouncer-mini spawns its background thread inside the
debouncer struct; dropping the struct kills the thread and discards
events still inside the debounce window. Consumers should hold this
handle for the lifetime of their server and call
WatcherHandle::retarget when their inputs change instead of
replacing it.
Implementations§
Source§impl WatcherHandle
impl WatcherHandle
Sourcepub fn retarget(&mut self, targets: WatchTargets) -> Result<()>
pub fn retarget(&mut self, targets: WatchTargets) -> Result<()>
Replace the watched roots, exact files, and ignored subtrees in place.
A replacement watcher would discard events this one has observed but not yet debounced, losing edits made while a host refreshes its inputs. Retargeting keeps the debouncer and unchanged roots registered, so those events are still delivered. Content baselines restart as they would for a new watcher: exact files are re-hashed and other paths forward their next event.
§Errors
Returns the first error from a path that exists but cannot be watched. The remaining paths are still registered, including requested roots nested inside the failed path, and the failed path is retried on the next retarget.