Expand description
File-index walker + filesystem watcher for the userβs project
tree. Speaks the language of paths, ignore::WalkBuilder walks,
and notify::Watcher events; produces typed snapshots and change
batches without knowing anything about session routing.
View consumers wrap these progress streams with their per-session
SessionSlot + generation routing; the env layer is route-blind.
Pattern mirrors env::git_diff (env owns subprocess + parsing,
workspace mediates, a view consumes via channel).
Re-exportsΒ§
use std::collections::BTreeSet;πuse std::path::Path;πuse std::path::PathBuf;πuse std::sync::Arc;πuse std::sync::atomic::AtomicBool;πuse std::sync::atomic::Ordering as AtomicOrdering;πuse std::sync::mpsc;πuse std::sync::mpsc::Receiver;πuse std::sync::mpsc::RecvTimeoutError;πuse std::time::Duration;πuse super::is_content_change;π
StructsΒ§
- Cancel
Token - Cancel guard for a backgrounded scan or watch. Drop to flip the shared atomic that producers poll between batches / events.
- File
Candidate - Watch
Filter π - Decides whether a watcher event path is worth acting on at all.
EnumsΒ§
- File
Index Change - Scan
Progress - Streaming-scan progress. Producers emit
Batchrepeatedly thenFinishedonce when the walk completes. - Watch
Progress - Watcher progress.
Changescarries a delta batch;Rebuildis a rescan signal (.gitignore changed or notify event we canβt classify).
ConstantsΒ§
- SCAN_
BATCH_ πSIZE - WATCH_
BATCH_ πCAP - Upper bound on events coalesced into one pass, so a sustained writer cannot starve the cancel check at the top of the loop.
- WATCH_
POLL_ πINTERVAL
FunctionsΒ§
- candidate_
basename - candidate_
from_ πentry - classify_
watch_ πevent - collect_
candidates - Synchronous walk that returns every candidate under
walk_root. Used by inline subtree refreshes triggered by watcher events. - collect_
create_ πor_ modify_ changes - collect_
parent_ πrescan_ changes - collect_
remove_ πchanges - collect_
rename_ πchanges - ensure_
dir_ πsuffix - for_
each_ πcandidate - Walk
walk_root(rooted relative toroot), invokingemitfor eachFileCandidate.emitreturningfalsecancels the walk. Returnstruewhen the walk completed naturally,falsewhen cancelled (either byemitβs return or the optional cancel flag). - is_
under_ πgit - Whether a root-relative path is under the rootβs own
.git- the walk drops it the way the watch does, with one ruling so the two cannot drift. - matches_
ignore_ πsemantics_ change - normalize_
relative_ πpath - normalized_
prefix π - replace_
subtree_ πchange - scan_
subtree π - start_
change_ watch - Spawn a recursive watch rooted at
rootthat reports ONE message per burst of changes the tree saw. - start_
scan - Spawn a streaming filesystem scan rooted at
root. Returns a receiver ofScanProgressbatches (Batchuntil the walker finishes, then one terminalFinished) and a cancel handle. Dropping the cancel handle aborts the walker. - start_
watch - Spawn a recursive filesystem watch rooted at
root. Returns a receiver ofWatchProgressevents and a cancel handle. Dropping the cancel handle stops the watcher.