Skip to main content

Module pattern_walk

Module pattern_walk 

Source
Expand description

Shared kernel for resolving a task’s InputSpec / OutputSpec patterns against the filesystem.

Two distinct consumers exist:

  • Cache-key input resolution resolves each declared InputSpec, reading the bytes of every match and folding them into the cache-key contents.
  • The executor’s output-store path resolves each declared OutputSpec after a successful run, recording the mode and host path of every match for the cache library to ingest.

Both consumers project workspace-anchored patterns onto the host filesystem the same way (literal_workspace_segments + host_path_from_segments for literals, glob_walk_origin + a recursive walker for globs); the only difference is what each one does once a regular-file match has been identified. This module captures the common projection helpers and the recursive walker, and parameterises the per-match work behind the GlobMatchAction trait.

Structs§

GlobWalk
Per-glob walk state: holds every immutable input the recursion needs, so the recursive methods take only the changing parts.

Traits§

GlobMatchAction
Per-consumer hooks for GlobWalk::walk.

Functions§

glob_walk_origin
Compute the glob-walk origin: the host directory at which the walk starts, the workspace-absolute prefix to prepend to every matched path ("/proj_root" for ProjectRelative + ProjectRoot::Nested; "" otherwise), and the candidate-string prefix that turns walk-relative segments into the spelling globset matches against ("/" for PathAnchor::WorkspaceAbsolute; "" for PathAnchor::ProjectRelative, matching each pattern’s Display form).
host_path_from_segments
Build a host filesystem path by pushing each workspace-segment’s string form onto workspace_root.
literal_workspace_segments
Lift a literal HazPath (under the supplied ProjectRoot) into its workspace-absolute segment view.
workspace_absolute_string_from_segments
Render a sequence of workspace-segments as a workspace-absolute path string ("/seg1/seg2/...").