Skip to main content

FileTree

Struct FileTree 

Source
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: FileNode

Root node of the tree.

§root_path: PathBuf

Root path that was scanned.

§scanned_at: SystemTime

When this scan was performed.

§scan_duration: Duration

Duration of the scan.

§config: ScanConfig

Scan configuration used.

§stats: TreeStats

Summary statistics.

§warnings: Vec<ScanWarning>

Warnings encountered during scan.

Implementations§

Source§

impl FileTree

Source

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.

Source

pub fn total_size(&self) -> u64

Get the total size of the tree.

Source

pub fn total_files(&self) -> u64

Get the total number of files.

Source

pub fn total_dirs(&self) -> u64

Get the total number of directories.

Source

pub fn has_warnings(&self) -> bool

Check if there were any warnings during scanning.

Source

pub fn warning_count(&self) -> u64

Observed warning count, including explicitly omitted details.

Source

pub fn find(&self, path: &Path) -> Option<&FileNode>

The entry at path, if it is the root or below it.

Source

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.

Source

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.

Source

pub fn recount(&mut self)

Recompute the summary statistics from the tree, after changes.

Source

pub fn remeasure(&mut self, apparent: bool, count_hard_links: bool)

Re-express every size in another measure without rescanning: apparent lengths or allocated blocks, with hard links counted once or each time.

Trait Implementations§

Source§

impl Clone for FileTree

Source§

fn clone(&self) -> FileTree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for FileTree

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<FileTree, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FileTree

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.