Skip to main content

walk_module_tree

Function walk_module_tree 

Source
pub fn walk_module_tree<E>(
    root: &Path,
    visitor: &mut dyn FnMut(&Path, u64) -> Result<(), E>,
) -> Result<TreeStats, WalkError<E>>
Expand description

Walks every regular file under root, enforcing containment and metadata exclusion. Calls visitor for each file with its path and size. Returns aggregate statistics.

Rules enforced:

  • Entries named .git or .sparse.json are skipped.
  • Symlinks whose canonical target is outside the module root are rejected with ModuleWalkError::SymlinkEscapesRoot.
  • Symlinks targeting non-module content (.git, .sparse.json) are rejected with ModuleWalkError::SymlinkTargetsMetadata.
  • Directory symlinks are rejected to prevent cycles.
  • Only regular files (and file symlinks to valid targets) are visited.