ParthJadhav
Rust_Search
Rust

Blazingly fast file search library built in Rust

Last updated Jul 6, 2026
192
Stars
17
Forks
4
Issues
+1
Stars/day
Attention Score
53
Language breakdown
Rust 100.0%
โ–ธ Files click to expand
README

bloom-banner-01-light-tags-1500x500

Group 1

Blazingly fast file search crate built in Rust ๐Ÿ”ฅ

Version info Downloads Documentation License

๐Ÿ“ฆ Usage

Please report any problems you encounter when using rust search here: Issues

Add rust_search = "2.2.0" in Cargo.toml.

[dependencies]
rust_search = "2.2.0"

Examples

  • General use
use rust_search::SearchBuilder;

let search: Vec<String> = SearchBuilder::default() .location("~/path/to/directory") .search_input("what to search") .more_locations(vec!["/anotherPath/to/search", "/keepAddingIfYouWant/"]) .limit(1000) // results to return .ext("extension") .strict() .depth(1) .ignore_case() .hidden() .build() .collect();

for path in search { println!("{}", path); }

  • Sort the output by similarity with the input
use rustsearch::{SearchBuilder, similaritysort};

let search_input = "fly"; let mut search: Vec<String> = SearchBuilder::default() .location("~/Desktop/") .searchinput(searchinput) .depth(1) .ignore_case() .build() .collect();

similaritysort(&mut search, &searchinput); for path in search { println!("{:?}", path); }

search without similarity sort
["afly.txt", "bfly.txt", "flyer.txt", "fly.txt"]

search with similarity sort
["fly.txt", "flyer.txt", "afly.txt", "bfly.txt",]
  • To get all the files with a specific extension in a directory, use:
use rust_search::SearchBuilder;

let files: Vec<String> = SearchBuilder::default() .location("/path/to/directory") .ext("file_extension") .build() .collect();

  • To get all the files in a directory, use:
use rust_search::SearchBuilder;

let files: Vec<String> = SearchBuilder::default() .location("/path/to/directory") .depth(1) .build() .collect();

  • To include files ignored by .gitignore, use:
use rust_search::SearchBuilder;

let files: Vec<String> = SearchBuilder::default() .location("/path/to/directory") .git_ignore(false) .build() .collect();

  • To skip expensive directories while walking, use:
use rust_search::SearchBuilder;

let files: Vec<String> = SearchBuilder::default() .location("/path/to/directory") .excludedirs(["nodemodules", "target"]) .build() .collect();

To filter files by datecreated, datemodified, filesize and/or customfilter, use:

use rust_search::{FileSize, FilterExt, SearchBuilder};
use std::time::{Duration, SystemTime};

let search: Vec<String> = SearchBuilder::default() .location("~/path/to/directory") .filesizegreater(FileSize::Kilobyte(200.0)) .filesizesmaller(FileSize::Megabyte(10.0)) .createdafter(SystemTime::now() - Duration::fromsecs(3600 24 10)) .created_before(SystemTime::now()) .modifiedafter(SystemTime::now() - Duration::fromsecs(3600 24 5)) .customfilter(|dir| dir.metadata().unwrap().isfile()) .custom_filter(|dir| !dir.metadata().unwrap().permissions().readonly()) .build() .collect();

Custom filters can capture values from their environment:

use rust_search::{FilterExt, SearchBuilder};

let suffix = ".rs".to_string(); let search: Vec<String> = SearchBuilder::default() .location("~/path/to/directory") .customfilter(move |dir| dir.path().tostringlossy().endswith(&suffix)) .build() .collect();

๐Ÿ‘‰ For more examples, please refer to the Documentation

โš™๏ธ Benchmarks

The difference in sample size is due to the fact that fd and glob are different tools and have different use cases. fd is a command line tool that searches for files and directories. glob is a library that can be used to search for files and directories. The benchmark is done on a MacBook Air M2, 16 GB Unified memory.

Benchmarks are done using hyperfine, Benchmarks files are available in the benchmarks drive folder.

- Rust Search vs Glob

The benchmark was done on a directories containing 300K files.

| Command / Library | Mean \[s] | Min \[s] | Max \[s] | Relative | |:---|---:|---:|---:|---:| | rust_search | 1.317 ยฑ 0.002 | 1.314 | 1.320 | 1.00 | | glob | 22.728 ยฑ 0.023 | 22.690 | 22.746 | 17.25 ยฑ 0.03 |


- Rust Search vs FD

The benchmark was done on a directories containing 45K files.

| Command / Library | Mean \[ms] | Min \[ms] | Max \[ms] | Relative | |:---|---:|---:|---:|---:| | rust_search | 680.5 ยฑ 2.1 | 678.3 | 683.6 | 1.00 | | fd -e .js | 738.7 ยฑ 10.2 | 720.8 | 746.7 | 1.09 ยฑ 0.02 |


Results:-

+ rust_search is 17.25 times faster than Glob.
  • rust_search** is 1.09 times faster than FD.

๐Ÿ‘จโ€๐Ÿ’ป Contributors

Any contributions would be greatly valued as this library is still in its early stages.

  • Documentation
  • Benchmarks
  • Implementation guidelines
  • Code Improvement
If you want to contribute to this project, please follow the steps below:
  • Fork the project
  • Clone the forked repository
  • Create a feature branch
  • Make changes to the code
  • Commit the changes
  • Push the changes to the forked repository
  • Create a pull request
  • Wait for the pull request to be reviewed and merged (if approved)

License

This project is licensed under the terms of the MIT license.

Discord server & Linkedin

Click the button below to join the discord server or Linkedin

Join Discord Server Connect on Linkedin

๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท ParthJadhav/Rust_Search ยท Updated daily from GitHub