pub struct FileTree {
pub root: FileNode,
pub root_path: PathBuf,
pub scanned_at: SystemTime,
pub scan_duration: Duration,
pub config: ScanConfig,
pub stats: TreeStats,
pub warnings: Vec<ScanWarning>,
}Expand description
Complete scanned file tree with metadata.
Warning: Clone performs a deep clone of the entire tree — O(n) in the number of nodes.
Fields§
§root: FileNodeRoot node of the tree.
root_path: PathBufRoot path that was scanned.
scanned_at: SystemTimeWhen this scan was performed.
scan_duration: DurationDuration of the scan.
config: ScanConfigScan configuration used.
stats: TreeStatsSummary statistics.
warnings: Vec<ScanWarning>Warnings encountered during scan.
Implementations§
Source§impl FileTree
impl FileTree
Sourcepub fn new(
root: FileNode,
root_path: PathBuf,
config: ScanConfig,
stats: TreeStats,
scan_duration: Duration,
warnings: Vec<ScanWarning>,
) -> Self
pub fn new( root: FileNode, root_path: PathBuf, config: ScanConfig, stats: TreeStats, scan_duration: Duration, warnings: Vec<ScanWarning>, ) -> Self
Create a new file tree.
scanned_at is stamped at construction time, which is when the scan
finished. scan_duration is supplied by the caller, so the scan’s start
time is scanned_at - scan_duration.
Sourcepub fn total_size(&self) -> u64
pub fn total_size(&self) -> u64
Get the total size of the tree.
Sourcepub fn total_files(&self) -> u64
pub fn total_files(&self) -> u64
Get the total number of files.
Sourcepub fn total_dirs(&self) -> u64
pub fn total_dirs(&self) -> u64
Get the total number of directories.
Sourcepub fn has_warnings(&self) -> bool
pub fn has_warnings(&self) -> bool
Check if there were any warnings during scanning.
Sourcepub fn warning_count(&self) -> u64
pub fn warning_count(&self) -> u64
Observed warning count, including explicitly omitted details.
Sourcepub fn find(&self, path: &Path) -> Option<&FileNode>
pub fn find(&self, path: &Path) -> Option<&FileNode>
The entry at path, if it is the root or below it.
Sourcepub fn remove(&mut self, path: &Path) -> Option<FileNode>
pub fn remove(&mut self, path: &Path) -> Option<FileNode>
Take the entry at path out of the tree, keeping every ancestor’s size
and counts consistent. The root cannot be removed. Call
Self::recount after a batch of changes.
Sourcepub fn insert(&mut self, parent: &Path, node: FileNode) -> bool
pub fn insert(&mut self, parent: &Path, node: FileNode) -> bool
Put node into the directory at parent, replacing any entry with
the same name, and keep every ancestor’s size and counts consistent.
Returns false, dropping node, if parent is not a directory in the
tree. Call Self::recount after a batch of changes.