pub fn watch_file(
path: &Path,
on_change: impl Fn(PathBuf) + Send + 'static,
) -> Result<FileWatch>Expand description
Report changes to path by calling on_change from the watcher’s thread.
Watches the parent directory, not the file. Editors and formatters write by rename-over, which destroys the inode a file watch is pinned to and leaves that watch pointed at nothing — the file keeps changing and the watcher keeps saying nothing. Watching the directory and filtering by name survives it, and also sees the file being deleted and recreated.
on_change is handed the path as it was given here, not the path the OS
reported, so a caller can compare it against what it has open without
worrying about how each platform spells it.