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>,
) -> FileTree
pub fn new( root: FileNode, root_path: PathBuf, config: ScanConfig, stats: TreeStats, scan_duration: Duration, warnings: Vec<ScanWarning>, ) -> FileTree
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileTree
impl<'de> Deserialize<'de> for FileTree
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileTree, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileTree, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for FileTree
impl Serialize for FileTree
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for FileTree
impl RefUnwindSafe for FileTree
impl Send for FileTree
impl Sync for FileTree
impl Unpin for FileTree
impl UnsafeUnpin for FileTree
impl UnwindSafe for FileTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more