| Crates.io | srusty-files |
| lib.rs | srusty-files |
| version | 0.2.0 |
| created_at | 2025-11-15 17:52:21.366684+00 |
| updated_at | 2025-11-15 17:52:21.366684+00 |
| description | A high-performance, cross-platform file search engine library with REST API |
| homepage | |
| repository | https://github.com/Aryagorjipour/rusty-files |
| max_upload_size | |
| id | 1934622 |
| size | 2,288,284 |
A high-performance, cross-platform file search engine library and CLI written in Rust.
Rusty Files is a production-grade file indexing and search library designed to be embedded in file managers, IDEs, system utilities, and any application requiring fast file discovery capabilities. It provides:
Add to your Cargo.toml:
[dependencies]
srusty-files = "0.1"
cargo install srusty-files
Or build from source:
git clone https://github.com/Aryagorjipour/rusty-files.git
cd rusty-files
cargo build --release
The binary will be available at target/release/filesearch.
use rusty_files::prelude::*;
fn main() -> Result<()> {
let engine = SearchEngine::new("./index.db")?;
engine.index_directory("/path/to/search", None)?;
let results = engine.search("*.rs")?;
for result in results {
println!("{}", result.file.path.display());
}
Ok(())
}
filesearch index /path/to/directory
filesearch search "*.rs"
filesearch search "test ext:rs size:>1KB modified:today"
filesearch interactive
filesearch stats
use rusty_files::prelude::*;
let engine = SearchEngine::builder()
.index_path("./index.db")
.thread_count(8)
.enable_content_search(true)
.enable_fuzzy_search(true)
.cache_size(1000)
.exclusion_patterns(vec![
".git".to_string(),
"node_modules".to_string(),
"target".to_string(),
])
.build()?;
let count = engine.index_directory("/path/to/dir", Some(Box::new(|progress| {
println!("Indexed: {}/{}", progress.current, progress.total);
})))?;
println!("Indexed {} files", count);
Simple search:
let results = engine.search("filename")?;
Advanced queries:
use rusty_files::{Query, MatchMode, SizeFilter};
let query = Query::new("test".to_string())
.with_match_mode(MatchMode::Fuzzy)
.with_extensions(vec!["rs".to_string(), "toml".to_string()])
.with_size_filter(SizeFilter::GreaterThan(1024))
.with_max_results(100);
let results = engine.search_with_query(&query)?;
Query string format:
let results = engine.search("pattern ext:rs,txt size:>1MB modified:today mode:fuzzy")?;
engine.start_watching("/path/to/watch")?;
std::thread::park();
engine.stop_watching()?;
let stats = engine.update_index("/path/to/dir", None)?;
println!("Added: {}, Updated: {}, Removed: {}",
stats.added, stats.updated, stats.removed);
let stats = engine.get_stats()?;
println!("Total files: {}", stats.total_files);
println!("Index size: {}", stats.index_size);
let verification = engine.verify_index("/path/to/dir")?;
println!("Health: {:.1}%", verification.health_percentage());
engine.vacuum()?;
engine.clear_index()?;
The query parser supports the following syntax:
filenamepattern ext:rs or pattern ext:rs,txt,mdpattern size:>1MB (greater than)pattern size:<500KB (less than)pattern size:1KB..10MB (range)pattern modified:todaypattern modified:yesterdaypattern modified:7days or pattern modified:1weekpattern modified:>2023-01-01pattern mode:fuzzy, mode:regex, mode:glob, mode:exactpattern scope:content, scope:path, scope:namepattern limit:100filesearch index <path>
filesearch index /home/user/projects --progress
filesearch update <path>
filesearch update /home/user/projects --progress
filesearch search "query"
filesearch search "*.rs"
filesearch search "test ext:rs size:>1KB modified:today"
filesearch search "function mode:regex scope:content"
filesearch stats
filesearch verify <path>
filesearch watch <path>
filesearch clear --confirm
filesearch vacuum
filesearch export --output results.json --query "*.rs"
filesearch export --output results.txt --query "test"
filesearch interactive
Interactive commands:
:help - Show help:stats - Show index statistics:history - Show search history:clear - Clear screen:quit - ExitConfiguration can be loaded from TOML or JSON files:
[config]
index_path = "./filesearch.db"
thread_count = 8
max_file_size_for_content = 10485760 # 10MB
enable_content_search = true
enable_fuzzy_search = true
fuzzy_threshold = 0.7
cache_size = 1000
bloom_filter_capacity = 10000000
bloom_filter_error_rate = 0.0001
max_search_results = 1000
batch_size = 1000
follow_symlinks = false
index_hidden_files = false
exclusion_patterns = [".git", "node_modules", "target", ".DS_Store"]
watch_debounce_ms = 500
enable_access_tracking = true
db_pool_size = 10
Load configuration:
use rusty_files::SearchConfig;
let config = SearchConfig::from_file(&PathBuf::from("config.toml"))?;
let engine = SearchEngine::with_config("./index.db", config)?;
Benchmark results from actual runs on the test environment:
| Files | Time (avg) | Throughput |
|---|---|---|
| 100 files | 101.96 ms | ~981 files/sec |
| 500 files | 406.47 ms | ~1,230 files/sec |
| 1000 files | 1.0491 s | ~953 files/sec |
| Incremental update | 646.82 ms | N/A |
| Operation | Time (avg) | Description |
|---|---|---|
| Simple search | 1.47 ms | Basic filename matching |
| Pattern search | 95.9 µs | Glob pattern matching |
| Fuzzy search | 1.25 ms | Fuzzy matching algorithm |
| Filtered search | 433.4 µs | Search with filters |
| Complex search | 1.22 ms | Multi-criteria search |
Test Environment: Linux 4.4.0, Release build with optimizations
Notes:
thread_count to CPU cores × 2┌─────────────────────────────────────────────────────────────┐
│ PUBLIC API LAYER │
│ ┌────────────┐ ┌──────────────┐ ┌──────────────────┐ │
│ │SearchEngine│ │ QueryBuilder │ │ ConfigManager │ │
│ └────────────┘ └──────────────┘ └──────────────────┘ │
└────────────┬────────────────┬────────────────┬──────────────┘
│ │ │
┌────────────▼────────────────▼────────────────▼──────────────┐
│ CORE ENGINE LAYER │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Indexer │ │ Searcher │ │ Watcher │ │ Ranker │ │
│ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │
└────────────┬────────────┬────────────┬──────────────────────┘
│ │ │
┌────────────▼────────────▼────────────▼──────────────────────┐
│ DATA ACCESS LAYER │
│ ┌────────────┐ ┌──────────────┐ ┌──────────────────┐ │
│ │ Index DB │ │ Cache Manager│ │ Bloom Filter │ │
│ │ (SQLite) │ │ (LRU) │ │ │ │
│ └────────────┘ └──────────────┘ └──────────────────┘ │
└──────────────────────────────────────────────────────────────┘
See the examples/ directory for complete examples:
basic_search.rs - Simple file searchingasync_indexing.rs - Asynchronous indexingcustom_config.rs - Custom configurationRun examples:
cargo run --example basic_search
Run tests:
cargo test
cargo test --all-features
cargo test --release
Run benchmarks:
cargo bench
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with:
For issues, questions, or suggestions, please open an issue.