Expand description
Parallel filesystem traversal backed by a work-stealing worker pool.
walk yields the root first, then workers read directories and distribute newly discovered
subdirectories among themselves. Order::ParentFirst publishes each directory’s entries
before scheduling its children, while Order::Completion allows descendant batches to arrive
first when their reads finish sooner. Sibling order is unspecified in both modes.
The descend predicate controls which directories are traversed; rejected directories are
still yielded (but not traversed).
Symbolic links are reported but never followed, and filesystem errors are
returned as iterator items. Dropping the iterator stops and joins its workers.
§Scheduling
The root directory starts in a shared injector queue. On platforms where directory-entry metadata may require another syscall, directory reads enqueue small metadata batches, and metadata batches enqueue accepted child directories. Windows workers instead consume the metadata returned by directory enumeration directly and enqueue child directories immediately. Every worker can run available jobs from its local LIFO queue or steal from a peer. Each successful thief wakes another idle worker, ramping up only while work remains stealable. A worker parks when no queue has work and is unparked when new work arrives or the walk stops. The last completed job emits the finished event; dropping the iterator stops and joins all workers.
Structs§
- Entry
- A filesystem entry produced by
walk. - File
Type - A structure representing a type of file with accessors for each file type.
It is returned by
Metadata::file_typemethod. - Metadata
- Metadata information about a file.
- Root
Walk - A multi-root iterator yielding each root index with entry and per-root completion events.
Unlike
Walk, it preserves root identity and exposes when each root finishes. - Walk
- A single-root directory iterator whose directory reads happen in parallel.
Unlike
RootWalk, it yields entries directly and hides root identity and completion events.
Enums§
- Order
- Controls when entries are yielded relative to their descendants.
- Root
Event - Per-root events exposed by
RootWalk. Unlike [Event], batches are flattened into entries and pool-wide completion ends the iterator instead of being yielded;Finishedtherefore means only that the associated root completed.RootWalkyields(root_idx, event), separating root routing from event meaning. [Event] cannot do this uniformly because itsFinishedvariant is pool-wide and has no root index.
Functions§
- walk
- Walk
rootwithout following symlinks. Unlikewalk_roots, this yields entries directly for a single root and hides completion events. - walk_
roots - Walk multiple indexed roots without following symlinks.
Unlike
walk, this preserves each root index and yields its completion as aRootEvent.