Skip to main content

snapcat/
lib.rs

1//! # Snapcat
2//!
3//! `snapcat` is a library for recursively walking a directory tree, building a tree representation,
4//! and reading the contents of files with options for binary detection, size limits, and more.
5//!
6//! It provides both a simple blocking API ([`snapcat`]) and a streaming API ([`SnapcatStream`]) when the
7//! `streaming` feature is enabled. Parallel file processing is available with the `parallel` feature.
8//!
9//! # Features
10//!
11//! - `parallel`: Enables parallel processing of files using Rayon.
12//! - `streaming`: Enables a streaming iterator API for processing files one by one.
13//! - `logging`: Enables debug logging via the `tracing` crate.
14//!
15//! # Example
16//!
17//! ```no_run
18//! use snapcat::{SnapcatBuilder, BinaryDetection, snapcat};
19//!
20//! let options = SnapcatBuilder::new(".")
21//!     .respect_gitignore(true)
22//!     .include_hidden(false)
23//!     .binary_detection(BinaryDetection::Accurate)
24//!     .file_size_limit(Some(10 * 1024 * 1024)) // 10 MB
25//!     .build();
26//!
27//! let result = snapcat(options).expect("Failed to scan directory");
28//!
29//! println!("Directory tree:\n{}", result.tree);
30//! for file in result.files {
31//!     println!("File: {} (binary: {})", file.path.display(), file.is_binary);
32//! }
33//! ```
34
35pub mod engine;
36pub mod error;
37pub mod options;
38pub mod output;
39pub mod tree;
40pub mod types;
41
42#[cfg(feature = "streaming")]
43pub use engine::SnapcatStream;
44pub use engine::snapcat;
45pub use error::SnapcatError;
46pub use options::{BinaryDetection, SnapcatBuilder, SnapcatOptions};
47pub use output::{OutputFormat, format_result, write_result_to_file};
48pub use types::{FileEntry, SnapcatResult};