pub struct Dir {
pub size: u64,
pub path: PathBuf,
pub contents: Option<Vec<Dir>>,
pub is_file: bool,
}Expand description
Structure that represents the directory tree or file
contains:
- size - the size of the directory/file in bytes
- path - the path to the directory/file
- contents - the contents of the directory (if it’s a directory)
Fields§
§size: u64§path: PathBuf§contents: Option<Vec<Dir>>§is_file: boolImplementations§
Source§impl Dir
impl Dir
Sourcepub fn new(
size: u64,
path: PathBuf,
contents: Option<Vec<Dir>>,
is_file: bool,
) -> Self
pub fn new( size: u64, path: PathBuf, contents: Option<Vec<Dir>>, is_file: bool, ) -> Self
Create a new directory/file
Args:
- size - the size of the directory/file
- path - the path to the directory/file
- contents - the contents of the directory (if it’s a directory)
pub fn from_entry(entry: DirEntry) -> Result<Dir, Error>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn name(&self) -> &str
pub fn size_formated(&self, size_fmt: &SizeFormat) -> (f32, &str)
Sourcepub fn display(&self, size_fmt: &SizeFormat) -> String
pub fn display(&self, size_fmt: &SizeFormat) -> String
String representation of the directory/file
pub fn display_default(&self) -> String
Sourcepub fn find(&self, path: &PathBuf) -> &Self
pub fn find(&self, path: &PathBuf) -> &Self
Recursively finds the parent Dir of a given path in the Dir structure
Sourcepub fn filter_size(&self, size_min: u64) -> Option<Vec<&Dir>>
pub fn filter_size(&self, size_min: u64) -> Option<Vec<&Dir>>
Filters the contents of dir that is bigger than size_min and returns new vector containing references to Dirs
Sourcepub fn sort_by_size(&mut self)
pub fn sort_by_size(&mut self)
Sorts the complete contents tree by size
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Dir
impl RefUnwindSafe for Dir
impl Send for Dir
impl Sync for Dir
impl Unpin for Dir
impl UnwindSafe for Dir
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