Expand description
A watch on exactly one file - forge.toml - so an edit reaches a
running forge without a restart.
The watch is on the file, never its directory: nothing else in the config dir can produce an event. An editorβs atomic save writes a temporary file and renames it over the path, and Syncthing applies an incoming change the same way, so the watch is re-armed on the path after every burst - a watch held on the replaced inode goes deaf.
A symlink repointed at a different target produces no event, because the backend watches the targetβs directory. Replace the file through the link, or edit the path the config dir actually names.
Re-exportsΒ§
use std::path::Path;πuse std::path::PathBuf;πuse std::time::Duration;πuse notify::RecommendedWatcher;πuse notify::RecursiveMode;πuse notify::Watcher as _;πuse tokio::sync::mpsc::UnboundedSender;πuse tokio::task::JoinHandle;π
StructsΒ§
- Config
Watch - A live watch. Dropping it stops the task and with it the watcher.
- Watched
Path π - Both spellings of the watched path: FSEvents reports real paths, so a
config dir reached through a symlink (
/varon macOS) needs the canonical one to match.
ConstantsΒ§
- DEBOUNCE π
- Coalescing window, measured from a burstβs first event. Later events inside it join the burst and do not extend it.
- REARM_
GRACE π - How long the fast retries run before the missing path is reported.
- REARM_
RETRY π - Re-arm retry while an atomic save has the path momentarily missing.
- REARM_
SLOW π - Re-arm cadence after that, so a file that reappears later is still watched and its contents apply.
FunctionsΒ§
- arm π
- arm_io π
- A notify failure as the
io::Errorthe re-arm classifies on.std::io::Error::otherwould erase the one kind that matters here: a path an atomic save has momentarily removed is expected, and everything else is forgeβs own problem. - event_
matches π - Whether one notify event means the watched file may have changed. A rescan says events were dropped and anything may have moved, and it carries no paths, so it is decided before the path test.
- rearm_
fast π - Re-arm for up to
REARM_GRACE, covering the gap an atomic save leaves.Nonemeans the path is still missing; the caller sends its notification anyway andslow_rearmkeeps trying. - slow_
rearm π - The path was missing past the grace window: keep a slow watch attempt running so a file that comes back later is seen and applies.
- unwatchable π
- watch
- Watch
pathand send one()per burst of content changes to it.