parex
Blazing-fast parallel search engine — generic, embeddable, zero opinions.
parex is a Rust library that owns the parallel walk engine, the trait contracts, and the error type. It does not own filesystem logic, output formatting, or built-in matchers — those belong to the caller.
Built to power ldx — a parallel file search CLI.
Features
- Parallel traversal via a clean
Sourcetrait — search files, databases, memory, anything - Custom matching via a
Matchertrait — substring, regex, fuzzy, metadata, ML scoring - Typed error handling with
is_recoverable()/is_fatal()— callers decide what to skip vs halt - Opt-in path and error collection — zero allocation overhead when unused
- Results are explicitly unordered — parallel traversal does not guarantee output order
#![forbid(unsafe_code)]
Install
Quick Start
Implement Source for whatever you want to search:
use ;
use WalkConfig;
;
Run a search:
let results = search
.source
.matching
.limit
.threads
.collect_paths
.collect_errors
.run?;
println!;
for path in &results.paths
Custom Matchers
use ;
;
let results = search
.source
.with_matcher
.collect_paths
.run?;
Builder API
| Method | Description |
|---|---|
.source(s) |
Set the source to search |
.matching(pattern) |
Substring match — case-insensitive shorthand |
.with_matcher(m) |
Custom Matcher implementation |
.limit(n) |
Stop after n matches |
.threads(n) |
Thread count (default: logical CPUs) |
.max_depth(d) |
Maximum traversal depth |
.collect_paths(bool) |
Collect matched paths into Results::paths |
.collect_errors(bool) |
Collect recoverable errors into Results::errors |
Error Handling
for err in &results.errors
Design
parex owns the walk engine, trait contracts, error type, and builder API. It does not own filesystem logic, output formatting, or concrete matchers — those live in the tool built on top.
Source and Matcher are the extension points. A caller wanting to search a database, an API, or a pre-built index just implements Source — the engine handles threading, result collection, and early exit transparently.
For filesystem traversal, parawalk is the recommended Source implementation — a minimal parallel directory walker designed to pair with parex.
See DOCS.md for the full architecture guide, custom source examples, and embedding parex in your own project.
License
MIT — see LICENSE