srcsearch
srcsearch indexes Rust source and Markdown documentation, then lets you query the result with Tantivy-based full-text search.
It can be used in two ways:
- CLI (
srcsearch) for local workflows and scripting. - Library (
srcsearch) for embedding indexing/search in your own Rust tooling.
Crates.io notes
- Package metadata includes license, categories, keywords, and docs.rs docs link.
- Test fixtures are excluded from published package contents to keep tarballs smaller.
What gets indexed
*.rsfiles (symbols, signatures, docs, and optional code snippets)*.mdfiles (section titles and body text)- Directory traversal skips common generated folders:
target,.git, andnode_modules.
CLI usage
The crate provides a binary named srcsearch with these subcommands:
json— build a JSON outputindex— build a Tantivy index directoryupdate— incrementally update an existing Tantivy index for changed filessearch— query a Tantivy index
Build and run
1) Generate a JSON output
Short form:
2) Build a Tantivy index directory
Short form:
--output-dirmust be empty (or not exist yet) when creating a fresh index.
3) Update an existing index after file changes
Short form:
4) Search the index
Search all fields (default scope):
Restrict search to documentation-focused fields only:
JSON output:
Search scopes
all(default): query title/body text + Rust symbol/signature/doc/code fieldsdoc: query title/body text + Rust doc fields only (ignores signatures/code)
Notes:
- Queries run against
title,body_text, and Rustdocfields use stemming, so inflected forms (for examplerunningvsrun) may match.
Library usage
Add srcsearch to your project (path dependency for local checkout shown):
[]
= { = "../srcsearch" }
Build records from a project (or a single target)
use Path;
use ;
Write JSON or Tantivy index
use Path;
use ;
Incremental update
use Path;
use ;
Search from code
use Path;
use ;
Development