Expand description
§FFF Search — High-performance file finder core
This crate provides the core search engine for FFF (Fast File Finder). It includes filesystem indexing with real-time watching, fuzzy matching powered by frizbee, frecency scoring backed by LMDB, and multi-mode grep search.
[!Important performance information]
For the most optimized fff build usezlobfeature. It requires zig v0.16.0 to be installed on the machine.
§Architecture
file_picker::FilePicker— Main entry point. Indexes a directory tree in a background thread, maintains a sorted file list, watches the filesystem for changes, and performs fuzzy search with frecency-weighted scoring.frecency::FrecencyTracker— LMDB-backed database that tracks file access and modification patterns for intelligent result ranking.query_tracker::QueryTracker— Tracks search query history and provides “combo-boost” scoring for repeatedly matched files.grep— Live grep search supporting regex, plain-text, and fuzzy modes with optional constraint filtering.git— Git status caching and repository detection.watch— Client-facing filesystem watch subscriptions: glob, exact path, or directory subtree with normalized batch delivery (seeSharedFilePicker::watch).
§Shared State
SharedFilePicker, SharedFrecency, and SharedQueryTracker are
newtype wrappers around Arc<RwLock<Option<T>>> for thread-safe shared
access. They provide read() / write() methods with built-in error
conversion and convenience helpers like wait_for_scan().
§Quick Start
use fff_search::file_picker::FilePicker;
use fff_search::frecency::FrecencyTracker;
use fff_search::query_tracker::QueryTracker;
use fff_search::{
FFFMode, FilePickerOptions, FuzzySearchOptions, PaginationArgs, QueryParser,
SharedFrecency, SharedFilePicker, SharedQueryTracker,
};
let shared_picker = SharedFilePicker::default();
let shared_frecency = SharedFrecency::default();
let shared_query_tracker = SharedQueryTracker::default();
let tmp = std::env::temp_dir().join("fff-doctest");
std::fs::create_dir_all(&tmp).unwrap();
// 1. Optionally initialize frecency and query tracker databases
let frecency = FrecencyTracker::open(tmp.join("frecency"))?;
shared_frecency.init(frecency)?;
let query_tracker = QueryTracker::open(tmp.join("queries"))?;
shared_query_tracker.init(query_tracker)?;
// 2. Init the file picker (spawns background scan + watcher)
FilePicker::new_with_shared_state(
shared_picker.clone(),
shared_frecency.clone(),
FilePickerOptions {
base_path: ".".into(),
mode: FFFMode::Ai,
..Default::default()
},
)?;
// 3. Wait for scan
shared_picker.wait_for_scan(std::time::Duration::from_secs(10));
// 4. Search: lock the picker and query tracker
let picker_guard = shared_picker.read()?;
let picker = picker_guard.as_ref().unwrap();
let qt_guard = shared_query_tracker.read()?;
// 5. Parse the query and perform fuzzy search
let parser = QueryParser::default();
let query = parser.parse("lib.rs");
let results = picker.fuzzy_search(
&query,
qt_guard.as_ref(),
FuzzySearchOptions {
max_threads: 0,
current_file: None,
pagination: PaginationArgs { offset: 0, limit: 50 },
..Default::default()
},
);
assert!(results.total_matched > 0);
assert!(results.items.first().unwrap().relative_path(picker).ends_with("lib.rs"));
let _ = std::fs::remove_dir_all(&tmp);Re-exports§
pub use rescan_stats::RESCAN_STATS_ENABLED;pub use rescan_stats::RescanReason;pub use rescan_stats::RescanStats;pub use watch::WatchEvent;pub use watch::WatchEventKind;pub use watch::WatchId;pub use watch::WatchOptions;pub use shared::*;pub use file_picker::*;pub use dbs::*;pub use grep::*;pub use types::*;
Modules§
- constants
- dbs
- Database-backed persistence: frecency, query history, LMDB plumbing.
- file_
picker - Core file picker single thread: filesystem indexing, background watching, and fuzzy search.
See
FilePickerfor the main entry point. Core file picker: filesystem indexing, background watching, and fuzzy search. - git
- Git status caching and repository detection utilities.
- glob_
detect - Glob wildcard detection — delegates to zlob when available, pure-Rust fallback otherwise.
- grep
- Live grep search with regex, plain-text, and fuzzy matching modes.
Live grep.
grep.rsimplements the main plain-text path, the parallel scan engine, and thegrep_searchentry point that picks the matcher/sink for every mode in one place;regex,multi_pattern, andfuzzy_grephold the mode-specific machinery on top of the sharedprefilter/sink. - location
- Location parsing for file:line:col patterns
- log
- Tracing/logging initialization
- path_
utils - Various path utils might be handy for you to work with fff paths
- rescan_
stats - Watcher rescan request accounting.
- shared
- Primary entry points with thread-safe
SharedFilePickerinstance - types
- Core data types shared across the crate.
- watch
- Filesystem watch subscriptions with glob filtering and batched delivery, plus the background OS watcher.
Structs§
- AiGrep
Config - Configuration for AI-mode grep — extends
GrepConfigbehavior with automatic file-path constraint detection. - DirSearch
Config - Configuration for directory and mixed search modes.
- FFFQuery
- File
Search Config - Default configuration for the file picker.
- Grep
Config - Configuration for full-text search (grep) - file constraints enabled for filtering which files to search, git status disabled since it’s not useful when searching file contents.
- Mixed
Search Config - Configuration for mixed (files + directories) search.
- Query
Parser - Main query parser - zero-cost wrapper around configuration
Enums§
- Constraint
- Constraint types that can be extracted from a query
- Error
- Fuzzy
Query - GitStatus
Filter - Location
Traits§
- Parser
Config - Parser configuration trait - allows different picker types to customize parsing
Functions§
- is_
filename_ constraint_ token Deprecated - Check if a token looks like a filename/path for use as a
FilePathconstraint.