| Crates.io | gravityfile-scan |
| lib.rs | gravityfile-scan |
| version | 0.2.2 |
| created_at | 2025-12-09 18:20:00.636719+00 |
| updated_at | 2026-01-16 13:09:34.582808+00 |
| description | File system scanning engine for gravityfile |
| homepage | |
| repository | https://github.com/epistates/gravityfile |
| max_upload_size | |
| id | 1975917 |
| size | 54,105 |
High-performance parallel file system scanner for gravityfile.
This crate provides the scanning engine that traverses directories and builds the file tree structure used by other gravityfile components.
use gravityfile_scan::{JwalkScanner, ScanConfig};
let config = ScanConfig::new("/path/to/scan");
let scanner = JwalkScanner::new();
let tree = scanner.scan(&config)?;
println!("Total size: {} bytes", tree.total_size());
println!("Total files: {}", tree.total_files());
println!("Total directories: {}", tree.total_dirs());
use gravityfile_scan::{JwalkScanner, ScanConfig, ScanProgress};
let scanner = JwalkScanner::new();
let mut progress_rx = scanner.subscribe();
// Spawn task to handle progress
tokio::spawn(async move {
while let Ok(progress) = progress_rx.recv().await {
println!(
"Scanned {} files, {} dirs ({} bytes)",
progress.files_scanned,
progress.dirs_scanned,
progress.bytes_scanned
);
}
});
let config = ScanConfig::new("/path/to/scan");
let tree = scanner.scan(&config)?;
use gravityfile_scan::{JwalkScanner, ScanConfig};
let config = ScanConfig::builder()
.root("/path/to/scan")
.max_depth(Some(5)) // Limit depth
.include_hidden(false) // Skip hidden files
.follow_symlinks(false) // Don't follow symlinks
.cross_filesystems(false) // Stay on same filesystem
.ignore_patterns(vec![
".git".into(),
"node_modules".into(),
"target".into(),
])
.threads(0) // 0 = auto-detect CPU count
.apparent_size(false) // Use disk usage, not apparent size
.build()?;
let scanner = JwalkScanner::new();
let tree = scanner.scan(&config)?;
The scanner produces a FileTree containing:
FileNode with nested childrenChildren are automatically sorted by size (largest first) for efficient display.
This crate re-exports common types from gravityfile-core for convenience:
use gravityfile_scan::{
FileNode, FileTree, NodeId, NodeKind,
ScanConfig, ScanError, ScanWarning,
Timestamps, TreeStats, WarningKind,
};
Licensed under either of Apache License, Version 2.0 or MIT license at your option.