std.text.search
std.text.search
Section titled “std.text.search”Search is the gateway from filesystem to stream. Typed results. Ordered parallelism.
std.text.search provides filesystem walking and pattern search, grafted from the proven ripgrep engine and integrated with std.text.stream.
Quick Example
Section titled “Quick Example”walk(p"src/") |> search(r/func \w+/) |> map(match => "${match.path}:${match.line}: ${match.text}") |> for_each(println)Core Types
Section titled “Core Types”SearchConfig
Section titled “SearchConfig”struct SearchConfig { ignore_git: bool = true, ignore_hidden: bool = true, follow_symlinks: bool = false, binary_detection: bool = true, max_depth: ?u32 = null,}SearchMatch
Section titled “SearchMatch”struct SearchMatch { path: Path, line: u64, column: u64, text: String,}SearchCaptureMatch
Section titled “SearchCaptureMatch”struct SearchCaptureMatch { path: Path, line: u64, column: u64, text: String, # Named capture groups as struct fields}Walk Configuration
Section titled “Walk Configuration”# Default configwalk(p"src/")
# Explicit configwalk(p"src/", SearchConfig{ ignore_git: true, ignore_hidden: false, max_depth: 5,})
# Modifier methodswalk(p"src/") |> respect_gitignore(true) |> respect_hidden(false) |> with_max_depth(3)Search Operations
Section titled “Search Operations”# Basic searchwalk(p"src/") |> search(r/func \w+/)
# Search with typed captureswalk(p"src/") |> search_with_captures(r/(?<name>\w+)\s*\((?<params>[^)]*)\)/)
# Case sensitivitywalk(p"src/") |> search(r/ERROR/, case_sensitive: true)Parallel Execution
Section titled “Parallel Execution”# Ordered (default) — deterministic outputwalk(p"src/") |> search(r/pattern/) |> parallel(4)
# Unordered — faster but nondeterministicwalk(p"src/") |> search(r/pattern/) |> parallel_unordered(4)Integration with Stream
Section titled “Integration with Stream”Search results feed into the stream pipeline:
walk(p"src/") |> search(r/func/) |> map($_.text) |> unique() |> count()Or use the stream literal:
<<walk(p"src/")>> |> search(r/func/) |> map($_.text)Typed Captures
Section titled “Typed Captures”walk(p"src/") |> search_with_captures(r/(?<type>struct|func)\s+(?<name>\w+)/) |> for_each(m => print("${m.type} ${m.name}") )Comparison
Section titled “Comparison”| Feature | Janus search | ripgrep CLI | grep (Unix) |
|---|---|---|---|
| Type safety | ✅ Static types | ❌ | ❌ |
| Typed captures | ✅ Struct fields | ❌ | ❌ |
| Stream integration | ✅ ` | >` pipeline | ⚠️ |
$1 ergonomics | ✅ :script | ❌ | ❌ |
| Ordered parallel | ✅ Default | ❌ | ❌ |
| Graft engine | ✅ ripgrep | — | ❌ |
Next Steps
Section titled “Next Steps”- TextStream — Stream processing
- Regex — Pattern matching
- PEG — Complex grammars
Search: the gateway from filesystem to stream.