pub struct TreeStats {
pub total_size: u64,
pub total_files: u64,
pub total_dirs: u64,
pub total_symlinks: u64,
pub max_depth: u32,
pub largest_file: Option<(PathBuf, u64)>,
pub oldest_file: Option<(PathBuf, SystemTime)>,
pub newest_file: Option<(PathBuf, SystemTime)>,
}Expand description
Summary statistics for a scanned tree.
Fields§
§total_size: u64Total size in bytes.
total_files: u64Total number of files.
total_dirs: u64Total number of directories.
total_symlinks: u64Total number of symbolic links.
max_depth: u32Maximum depth reached.
largest_file: Option<(PathBuf, u64)>Largest file (path, size).
oldest_file: Option<(PathBuf, SystemTime)>Oldest file (path, time).
newest_file: Option<(PathBuf, SystemTime)>Newest file (path, time).
Implementations§
Source§impl TreeStats
impl TreeStats
Sourcepub fn record_file(
&mut self,
path: &Path,
size: u64,
modified: Option<SystemTime>,
depth: u32,
)
pub fn record_file( &mut self, path: &Path, size: u64, modified: Option<SystemTime>, depth: u32, )
Update stats with a file entry. Only clones the path when updating a tracked field. Equal sizes/times choose the smallest native path, independent of arrival order.
modified is None when the file’s modification time could not be read;
such files are excluded from oldest/newest tracking rather than being
coerced to the Unix epoch (which would poison the “oldest file” result).
Sourcepub fn record_file_with(
&mut self,
size: u64,
modified: Option<SystemTime>,
depth: u32,
path: impl FnOnce() -> PathBuf,
)
pub fn record_file_with( &mut self, size: u64, modified: Option<SystemTime>, depth: u32, path: impl FnOnce() -> PathBuf, )
Self::record_file that builds the path only when it is needed:
when this file may become the largest, oldest or newest.
Sourcepub fn record_dir(&mut self, depth: u32)
pub fn record_dir(&mut self, depth: u32)
Record a directory.
Sourcepub fn record_symlink(&mut self)
pub fn record_symlink(&mut self)
Record a symlink.