Skip to main content

Module file_index

Module file_index 

Source
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Β§

CancelToken
Cancel guard for a backgrounded scan or watch. Drop to flip the shared atomic that producers poll between batches / events.
FileCandidate
WatchFilter πŸ”’
Decides whether a watcher event path is worth acting on at all.

EnumsΒ§

FileIndexChange
ScanProgress
Streaming-scan progress. Producers emit Batch repeatedly then Finished once when the walk completes.
WatchProgress
Watcher progress. Changes carries a delta batch; Rebuild is 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 to root), invoking emit for each FileCandidate. emit returning false cancels the walk. Returns true when the walk completed naturally, false when cancelled (either by emit’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 root that reports ONE message per burst of changes the tree saw.
start_scan
Spawn a streaming filesystem scan rooted at root. Returns a receiver of ScanProgress batches (Batch until the walker finishes, then one terminal Finished) and a cancel handle. Dropping the cancel handle aborts the walker.
start_watch
Spawn a recursive filesystem watch rooted at root. Returns a receiver of WatchProgress events and a cancel handle. Dropping the cancel handle stops the watcher.