Skip to main content

Crate fff_query_parser

Crate fff_query_parser 

Source
Expand description

Fast query parser for file search

This parser takes a search query and extracts structured constraints while preserving text for fuzzy matching. Designed for maximum performance:

  • Single-pass parsing with minimal branching
  • Stack-allocated string buffers

§Examples

use fff_query_parser::{QueryParser, Constraint, FuzzyQuery};

let parser = QueryParser::default();

// Single-token queries return FFFQuery with Text fuzzy query and no constraints
let result = parser.parse("hello");
assert!(result.constraints.is_empty());
assert_eq!(result.fuzzy_query, FuzzyQuery::Text("hello"));

// Multi-token queries are parsed
let result = parser.parse("name *.rs");
match &result.fuzzy_query {
    FuzzyQuery::Text(text) => assert_eq!(*text, "name"),
    _ => panic!("Expected text"),
}
assert!(matches!(result.constraints[0], Constraint::Extension("rs")));

// Parse glob pattern with text
let result = parser.parse("**/*.rs foo");
assert!(matches!(result.constraints[0], Constraint::Glob("**/*.rs")));

// Parse negation
let result = parser.parse("!*.rs foo");
match &result.constraints[0] {
    Constraint::Not(inner) => {
        assert!(matches!(inner.as_ref(), Constraint::Extension("rs")));
    }
    _ => panic!("Expected Not constraint"),
}

Re-exports§

pub use location::Location;

Modules§

glob_detect
Glob wildcard detection — delegates to zlob when available, pure-Rust fallback otherwise.
location
Location parsing for file:line:col patterns

Structs§

AiGrepConfig
Configuration for AI-mode grep — extends GrepConfig behavior with automatic file-path constraint detection.
FFFQuery
FileSearchConfig
Default configuration for file picker - all features enabled
GrepConfig
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.
QueryParser
Main query parser - zero-cost wrapper around configuration

Enums§

Constraint
Constraint types that can be extracted from a query
FuzzyQuery
GitStatusFilter

Traits§

ParserConfig
Parser configuration trait - allows different picker types to customize parsing

Type Aliases§

ConstraintVec