| Crates.io | gravityfile-core |
| lib.rs | gravityfile-core |
| version | 0.2.2 |
| created_at | 2025-12-09 18:19:56.495535+00 |
| updated_at | 2026-01-16 13:09:31.504562+00 |
| description | Core types and traits for gravityfile |
| homepage | |
| repository | https://github.com/epistates/gravityfile |
| max_upload_size | |
| id | 1975915 |
| size | 49,245 |
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.
Represents a single file system entry:
use gravityfile_core::{FileNode, NodeId, Timestamps, NodeKind};
use std::time::SystemTime;
// Create a file node
let file = FileNode::new_file(
NodeId::new(1),
"example.txt",
1024, // size in bytes
2, // disk blocks
Timestamps::with_modified(SystemTime::now()),
false, // not executable
);
// Create a directory node
let dir = FileNode::new_directory(
NodeId::new(2),
"my_folder",
Timestamps::with_modified(SystemTime::now()),
);
Container for scan results:
use gravityfile_core::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
Configuration for scanning operations:
use gravityfile_core::ScanConfig;
// Simple configuration
let config = ScanConfig::new("/path/to/scan");
// Advanced configuration with builder
let config = ScanConfig::builder()
.root("/path/to/scan")
.max_depth(Some(10))
.include_hidden(false)
.follow_symlinks(false)
.cross_filesystems(false)
.ignore_patterns(vec![".git".into(), "node_modules".into()])
.build()
.unwrap();
Summary statistics for a scanned tree:
use gravityfile_core::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)>
use gravityfile_core::{ScanError, ScanWarning, WarningKind};
// 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
Licensed under either of Apache License, Version 2.0 or MIT license at your option.