Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

Rust_Search

> 编程语言
Open source

Blazingly fast file search library built in Rust

192 stars0 likes1 views
WebsiteGitHub

About

Blazingly fast file search library built in Rust

Usage

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

Add rust_search = "2.2.0" in Cargo.toml.

toml
[dependencies]
rust_search = "2.2.0"

Examples

  • General use
rust
use rust_search::SearchBuilder;

let search: Vec = 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
rust
use rust_search::{SearchBuilder, similarity_sort};

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

similarity_sort(&mut search, &search_input);
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:
rust
use rust_search::SearchBuilder;

let files: Vec = SearchBuilder::default()
    .location("/path/to/directory")
    .ext("file_extension")
    .build()
    .collect();
  • To get all the files in a directory, use:
rust
use rust_search::SearchBuilder;

let files: Vec = SearchBuilder::default()
    .location("/path/to/directory")
    .depth(1)
    .build()
    .collect();
  • To include files ignored by .gitignore, use:
rust
use rust_search::SearchBuilder;

let files: Vec = SearchBuilder::default()
    .location("/path/to/directory")
    .git_ignore(false)
    .build()
    .collect();
  • To skip expensive directories while walking, use:
rust
use rust_search::SearchBuilder;

let files: Vec = SearchBuilder::default()
    .location("/path/to/directory")
    .exclude_dirs(["node_modules", "target"])
    .build()
    .collect();

To filter files by date_created, date_modified, file_size and/or custom_filter, use:

…

Custom filters can capture values from their environment:

rust
use rust_search::{FilterExt, SearchBuilder};

let suffix = ".rs".to_string();
let search: Vec = SearchBuilder::default()
    .location("~/path/to/directory")
    .custom_filter(move |dir| dir.path().to_string_lossy().ends_with(&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:-

diff
+ 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:

  1. Fork the project
  2. Clone the forked repository
  3. Create a feature branch
  4. Make changes to the code
  5. Commit the changes
  6. Push the changes to the forked repository
  7. Create a pull request
  8. 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

Author

Created by Parth Jadhav.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustcratefastfilesearchfilesystem

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言