pub struct DiskUse { /* private fields */ }Expand description
Main interface for disk usage analysis with caching support
Implementations§
Source§impl DiskUse
impl DiskUse
Sourcepub fn new(cache_path: impl AsRef<Path>) -> Self
pub fn new(cache_path: impl AsRef<Path>) -> Self
Create a new DiskUse instance with the specified cache file path
Sourcepub fn new_with_default_cache() -> Self
pub fn new_with_default_cache() -> Self
Create a new DiskUse instance using the default cache location
Sourcepub fn scan(&mut self, path: impl AsRef<Path>) -> Result<u64>
pub fn scan(&mut self, path: impl AsRef<Path>) -> Result<u64>
Scan a directory and return its total size in bytes
This method automatically:
- Loads from cache
- Scans only changed directories
- Saves the updated cache
Sourcepub fn scan_with_options(
&mut self,
path: impl AsRef<Path>,
ignore_cache: bool,
) -> Result<u64>
pub fn scan_with_options( &mut self, path: impl AsRef<Path>, ignore_cache: bool, ) -> Result<u64>
Scan a directory with options for ignoring cache
§Arguments
path- The directory path to scanignore_cache- If true, performs a fresh scan without using cache
Sourcepub fn get_stats(&self, path: impl AsRef<Path>) -> Option<&DirStat>
pub fn get_stats(&self, path: impl AsRef<Path>) -> Option<&DirStat>
Get detailed statistics for a previously scanned path
Sourcepub fn get_file_count(
&self,
path: impl AsRef<Path>,
ignore_cache: bool,
) -> Result<u64>
pub fn get_file_count( &self, path: impl AsRef<Path>, ignore_cache: bool, ) -> Result<u64>
Get file count for a path
§Arguments
path- The path to get file count forignore_cache- If true, counts files directly from filesystem instead of using cache
Sourcepub fn save_cache(&mut self) -> Result<()>
pub fn save_cache(&mut self) -> Result<()>
Save the current cache to disk
Sourcepub fn clear_cache(&mut self) -> Result<()>
pub fn clear_cache(&mut self) -> Result<()>
Clear all cache contents
Sourcepub fn delete_cache(&self) -> Result<()>
pub fn delete_cache(&self) -> Result<()>
Delete the cache file
Sourcepub fn cache_path(&self) -> &Path
pub fn cache_path(&self) -> &Path
Get the cache file path
Sourcepub fn get_cached_roots(&self) -> Vec<&DirStat>
pub fn get_cached_roots(&self) -> Vec<&DirStat>
Get all cached root directories
Sourcepub fn is_cache_empty(&self) -> bool
pub fn is_cache_empty(&self) -> bool
Check if the cache is empty
Auto Trait Implementations§
impl Freeze for DiskUse
impl RefUnwindSafe for DiskUse
impl Send for DiskUse
impl Sync for DiskUse
impl Unpin for DiskUse
impl UnwindSafe for DiskUse
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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