gravityfile-core
Core types and traits for the gravityfile ecosystem.
This crate provides the fundamental data structures used throughout gravityfile, including file nodes, trees, configuration, and error types.
Features
- FileNode - Represents files, directories, and symlinks with metadata
- FileTree - Container for scanned directory trees with statistics
- ScanConfig - Configuration for directory scanning operations
- Content Hashing - BLAKE3-based content hashing for duplicate detection
- Full Serialization - All types implement Serde for JSON export
Types
FileNode
Represents a single file system entry:
use ;
use SystemTime;
// Create a file node
let file = new_file;
// Create a directory node
let dir = new_directory;
FileTree
Container for scan results:
use FileTree;
// FileTree is typically created by gravityfile-scan
// It contains:
// - root: FileNode - the root directory node
// - root_path: PathBuf - absolute path that was scanned
// - stats: TreeStats - summary statistics
// - warnings: Vec<ScanWarning> - issues encountered during scan
ScanConfig
Configuration for scanning operations:
use ScanConfig;
// Simple configuration
let config = new;
// Advanced configuration with builder
let config = builder
.root
.max_depth
.include_hidden
.follow_symlinks
.cross_filesystems
.ignore_patterns
.build
.unwrap;
TreeStats
Summary statistics for a scanned tree:
use TreeStats;
// TreeStats provides:
// - total_size: u64 - total bytes
// - total_files: u64 - file count
// - total_dirs: u64 - directory count
// - total_symlinks: u64 - symlink count
// - max_depth: u32 - deepest nesting level
// - largest_file: Option<(PathBuf, u64)>
// - oldest_file: Option<(PathBuf, SystemTime)>
// - newest_file: Option<(PathBuf, SystemTime)>
Error Handling
use ;
// ScanError variants:
// - Io { path, source } - I/O errors
// - NotADirectory { path } - path is not a directory
// - Config { message } - invalid configuration
// ScanWarning for non-fatal issues:
// - ReadError - couldn't read a file/directory
// - MetadataError - couldn't get metadata
// - BrokenSymlink - symlink target doesn't exist
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.