#file-path #file-processing #channel #recursion #filter #crossbeam #customizable

file_traverser

file_traverser is a Rust crate designed for efficient file system traversal. It allows users to recursively explore directories and filter files based on customizable criteria. The crate supports both standard library mpsc and crossbeam channels through a trait, enabling flexible communication patterns for sending file paths. Ideal for applications that require asynchronous file processing, it combines ease of use with powerful functionality.

3 releases

0.1.2 Oct 17, 2024
0.1.1 Oct 17, 2024
0.1.0 Oct 16, 2024

#578 in Filesystem

Download history 344/week @ 2024-10-13 47/week @ 2024-10-20 3/week @ 2024-10-27 9/week @ 2024-11-03

75 downloads per month

GPL-3.0 license

17KB
173 lines

file_traverser

file_traverser is a Rust crate that provides an efficient way to traverse file systems recursively while applying customizable filters to files. It supports both standard library mpsc and crossbeam channels, allowing you to choose the best communication method for your application.

Features

  • Recursive Directory Traversal: Explore directories and their subdirectories.
  • Customizable Filtering: Apply user-defined filters to select specific files.
  • Channel Support: Use either standard library mpsc or crossbeam channels for sending file paths.
  • Asynchronous Processing: Designed for efficient asynchronous file handling.

Installation

Add the following line to your Cargo.toml:

[dependencies]
file_traverser = "0.1"

Usage

Here's a basic example of how to use file_traverser:

use std::path::PathBuf;
use std::sync::mpsc::channel;
use file_traverser::filter_and_send_files;

fn main() {
    let (tx, rx) = channel();

    // Define a filter function
    let filter = |path: &Path| path.extension().map(|ext| ext == "txt").unwrap_or(false);

    // Start traversing
    filter_and_send_files(&PathBuf::from("path/to/directory"), tx, filter);

    // Receive paths
    for received in rx {
        println!("Received file: {:?}", received);
    }
}

Dependencies

~2MB
~32K SLoC