Giter Site home page Giter Site logo

parthjadhav / rust_search Goto Github PK

View Code? Open in Web Editor NEW
127.0 4.0 11.0 34 KB

Blazingly fast file search library built in Rust

License: MIT License

Rust 100.00%
rust crate fast filesearch filesystem hacktoberfest library recursive-algorithm rust-lang search-algorithm

rust_search's Introduction

Hi there, I'm Parth Jadhav ๐Ÿ‘‹

Passionate full-stack developer skilled in Rust, TypeScript, Node.js, React.js, and cloud integration, creating innovative solutions for real-world problems, collaborative and driven, always up for a challenge, and loves the outdoors and trying new coffee shops.

๐Ÿ‘‰ Explore all my projects, including those that aren't open source, on my Bento profile.

GitHub followers Linkedin

rust_search's People

Contributors

jewlexx avatar mucks avatar parthjadhav avatar simonmonecke avatar theawiteb avatar weykon avatar xithrius avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rust_search's Issues

Is there any example using this library in c++?

This is a cool library. I want to using this library in my c++ project, but I cannot find any example. I know I can use rust cxx to embed rust library to c++, but that's not easy to return string vector from rust to c++.
So hope any cxx/c++ exmaple using this library. Have you ever tired cxx? It will be awsome to have an example of that.

Low speed on x86_64-unknown-linux-musl

Why so different speed for some targets?
For x86_64-unknown-linux-gnu

./target/release/walk    
Time elapsed: 1.022172369s
Found 11 files

and x7 slow for x86_64-unknown-linux-musl

./target/x86_64-unknown-linux-musl/release/walk
Time elapsed: 7.560947213s
Found 11 files

Why?

[Feature Request]: Make `Search` struct easier

Breaking changes

I think add search instance function to Search struct will make it easier. This will make it easier to do something like this

use rust_search::Search;

fn main() {
    let mains = Search::default().input("main").search();
    let readmes = Search::default().input("readme")
    .ignore_case() // will ignore ascii case
    .extension("md")
    .search();
}

[Feature]: Sort the paths by file names

Currently the results are scattered & random.

Eg:

Current output:
Search input: "a"
Search output: ["man", "cat", "ant", "ban", "tan"]

Expected result with .sort(true) :
Search input: "a"
Search output: ["ant", "ban", "cat", "man", "tan"]

[Bug]: Search work without file extension, but with it's not

^ Title

For example i have file it's name is some_random_word_yes_it_is.md in /home/User/foo/bar/

use rust_search::Search;

fn main(){
    let search = Search::new(
        "/home/User/foo/bar/",
        Some("yes"),
        None,
        None);

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

This will work, but when i add the file extinction it's not, for example

use rust_search::Search;

fn main(){
    let search = Search::new(
        "/home/User/foo/bar/",
        Some("yes"),
        Some(".md"), // also "md"
        None);

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

Return &Path or OsString object from iter

I am very impressed with the simplicity and speed of your solution!

Are you planning to abandon the use of String as a return value in the future? On Linux, this can create some problems, as far as I can tell.

[Bug]: Search input includes `location` to search for

let search: Vec<String> = SearchBuilder::default()
        .location("/System/")
        .search_input("Syste")
        .depth(1)
        .ignore_case()
        .build()
        .collect();

This will return everything contained in /System/ directory because the Regex will be matched with the path input i.e /System/ and return everything.

This could be solved by adding: .split("/").last().unwrap() to path

reg_exp.is_match(&path.split("/").last().unwrap())

@TheAwiteb , Is there a better way to do this? Or are there any implications using this approach ?

[request] Add example of returning results

I'm a total newb to Rust. Trying to figure out how to use this library in the context of https://github.com/tauri-apps/tauri but am having trouble getting the return value right. Trying to have it return the file paths in a simple array (to be used in JS).

Based on the example code:

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);
    }

   // How to return `search` here as a simple array?
}

I've tried simply adding:

return search;

But that returns "expected (), found struct Vec".

I know that for Rust developers this is likely embarrassingly simple. Please forgive my ignorance! I've done quite a bit of searching and tested different things but nothing has worked.

Is it possible to exclude directories?

This would help performance when using a high depth value and knowing that desired results are not in directories {...}. For example, node_modules (which often have deeply nested structures with lots of files).

rust_search::Filesize cannot be imported

error[E0432]: unresolved import rust_search::FileType
--> src/main.rs:3:5
|
3 | use rust_search::FileType;
| ^^^^^^^^^^^^^^^^^^^^^ no FileType in the root
|
help: consider importing this struct instead
|
3 | use std::fs::FileType;
| ~~~~~~~~~~~~~~~~~~

error[E0433]: failed to resolve: use of undeclared type FileSize

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.