Crates.io | file_traverser |
lib.rs | file_traverser |
version | 0.1.2 |
source | src |
created_at | 2024-10-16 15:30:22.919771 |
updated_at | 2024-10-17 05:04:46.080994 |
description | 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. |
homepage | |
repository | https://github.com/itsscb/file_traverser |
max_upload_size | |
id | 1411937 |
size | 46,695 |
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.
mpsc
or crossbeam
channels for sending file paths.Add the following line to your Cargo.toml
:
[dependencies]
file_traverser = "0.1"
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);
}
}