pub struct DirEntry {
pub path: PathBuf,
pub name: String,
pub is_dir: bool,
pub size: u64,
pub disk_usage: u64,
pub file_count: u64,
pub dir_count: u64,
pub mtime: Option<SystemTime>,
pub children: Vec<DirEntry>,
pub error: Option<String>,
}Expand description
Represents a file or directory with its metadata and size information. This is the core data structure for the disk scanner.
Fields§
§path: PathBufFull path to the file or directory
name: StringEntry name (last component of path)
is_dir: boolTrue if this is a directory
size: u64Apparent size in bytes (sum of file sizes)
disk_usage: u64Actual disk usage in bytes (accounting for block size)
file_count: u64Number of files (1 for files, recursive count for dirs)
dir_count: u64Number of subdirectories (recursive)
mtime: Option<SystemTime>Last modification time
children: Vec<DirEntry>Child entries (empty for files)
error: Option<String>Error message if we couldn’t read this entry (permission denied, etc.)
Implementations§
Source§impl DirEntry
impl DirEntry
Sourcepub fn shallow_clone(&self) -> Self
pub fn shallow_clone(&self) -> Self
Clone this entry’s display metadata without recursively cloning children.
Sourcepub fn new_file(
path: PathBuf,
size: u64,
disk_usage: u64,
mtime: Option<SystemTime>,
) -> Self
pub fn new_file( path: PathBuf, size: u64, disk_usage: u64, mtime: Option<SystemTime>, ) -> Self
Create a new file entry from metadata
Sourcepub fn new_dir(path: PathBuf, mtime: Option<SystemTime>) -> Self
pub fn new_dir(path: PathBuf, mtime: Option<SystemTime>) -> Self
Create a new directory entry (children added later)
Sourcepub fn new_error(path: PathBuf, error: String) -> Self
pub fn new_error(path: PathBuf, error: String) -> Self
Create an error entry for inaccessible paths
Sourcepub fn recalculate_totals(&mut self)
pub fn recalculate_totals(&mut self)
Recalculate size totals from children
Sourcepub fn sort_by_size(&mut self)
pub fn sort_by_size(&mut self)
Sort children by size (largest first)
Sourcepub fn sort_by_name(&mut self)
pub fn sort_by_name(&mut self)
Sort children by name (alphabetical)
Sourcepub fn total_entries(&self) -> u64
pub fn total_entries(&self) -> u64
Get total entry count (self + all descendants)
Trait Implementations§
Source§impl From<&DirEntry> for SummarizedEntry
impl From<&DirEntry> for SummarizedEntry
Auto Trait Implementations§
impl Freeze for DirEntry
impl RefUnwindSafe for DirEntry
impl Send for DirEntry
impl Sync for DirEntry
impl Unpin for DirEntry
impl UnsafeUnpin for DirEntry
impl UnwindSafe for DirEntry
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,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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