ProductPromotion
Logo

Rust

made by https://0x3d.site

GitHub - ParthJadhav/Rust_Search: Blazingly fast file search library built in Rust
Blazingly fast file search library built in Rust. Contribute to ParthJadhav/Rust_Search development by creating an account on GitHub.
Visit Site

GitHub - ParthJadhav/Rust_Search: Blazingly fast file search library built in Rust

GitHub - ParthJadhav/Rust_Search: Blazingly fast file search library built in Rust

Group 1

Blazingly fast file search crate built in Rust 🔥

Version info Documentation License

📦 Usage

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

Add rust_search = "2.0.0" in Cargo.toml.

[dependencies]
rust_search = "2.0.0"

Examples

  • General use
use rust_search::SearchBuilder;

fn main(){
    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 rust_search::{SearchBuilder, similarity_sort};
 fn main() {
     let search_input = "fly";
     let mut search: Vec<String> = 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:
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 filter files by date_created, date_modified, file_size and/or custom_filter, use:

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

let search: Vec<String> = SearchBuilder::default()
		.location("~/path/to/directory")
		.file_size_greater(FileSize::Kilobyte(200.0))
		.file_size_smaller(FileSize::Megabyte(10.0))
		.created_after(SystemTime::now() - Duration::from_secs(3600 * 24 * 10))
		.created_before(SystemTime::now())
		.modified_after(SystemTime::now() - Duration::from_secs(3600 * 24 * 5))
		.custom_filter(|dir| dir.metadata().unwrap().is_file())
		.custom_filter(|dir| !dir.metadata().unwrap().permissions().readonly())
		.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:

  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

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory