Skip to main content

FileNode

Struct FileNode 

Source
pub struct FileNode {
    pub name: CompactString,
    pub native_name: Option<Box<OsString>>,
    pub kind: NodeKind,
    pub size: u64,
    pub len: u64,
    pub blocks: u64,
    pub timestamps: Timestamps,
    pub inode: Option<InodeInfo>,
    pub git_status: Option<GitStatus>,
    pub children: Vec<FileNode>,
}
Expand description

A single file or directory in the tree.

Debug formatting includes this node’s metadata and direct child count, not descendant contents, so logging a node does not walk the entire tree.

Fields§

§name: CompactString

File/directory name (not full path).

§native_name: Option<Box<OsString>>

Exact platform filename when the display name cannot represent it.

§kind: NodeKind

Node type and associated metadata.

§size: u64

Size in bytes: disk usage, or apparent length when the scan used apparent sizes. Directories aggregate their contents and their own allocation; additional hard links to a counted file contribute zero. Derived from len and blocks; see FileNode::remeasure.

§len: u64

Apparent length of this entry itself (st_size), not aggregated.

§blocks: u64

512-byte blocks allocated to this entry itself (not aggregated).

§timestamps: Timestamps

File metadata timestamps.

§inode: Option<InodeInfo>

Identity of multiply-linked files, for hard-link aware analysis.

§git_status: Option<GitStatus>

Git status for this file/directory.

§children: Vec<FileNode>

Children nodes (directories only), sorted by size descending.

Implementations§

Source§

impl FileNode

Source

pub fn compare_name(&self, other: &FileNode) -> Ordering

Compare compatibility labels with exact native identity as a tiebreak.

Source

pub fn display_name(&self) -> Cow<'_, str>

Terminal-safe filename label that preserves visible byte distinctions.

Source

pub fn file_name(&self) -> &OsStr

Filename component for filesystem access; name is display text only.

Source

pub fn set_file_name(&mut self, name: &OsStr)

Preserve an exact component while retaining a Unicode display label.

Source

pub fn new_file( name: impl Into<CompactString>, size: u64, blocks: u64, timestamps: Timestamps, executable: bool, ) -> FileNode

Create a new file node.

Source

pub fn new_directory( name: impl Into<CompactString>, timestamps: Timestamps, ) -> FileNode

Create a new, empty directory node.

Create a symbolic link node.

Source

pub fn is_dir(&self) -> bool

Check if this node is a directory.

Source

pub fn is_file(&self) -> bool

Check if this node is a file.

Source

pub fn child_count(&self) -> usize

Get the number of direct children.

Source

pub fn file_count(&self) -> u64

Get file count for directories (includes files, symlinks, and other entries), 1 for files/symlinks/other.

Source

pub fn dir_count(&self) -> u64

Get directory count for directories.

Source

pub fn sort_children_by_size(&mut self)

Sort children by size descending, breaking ties by name and native name.

Uses stored sizes without recomputing them. Traversal retains one child iterator per directory depth instead of using recursive calls.

Source

pub fn update_counts(&mut self)

Update directory file/dir counts with an iterative post-order traversal.

Retains one traversal frame per directory depth. Symlinks and Other entries are counted in the file count; non-directory children are leaves.

Source

pub fn finalize(&mut self)

Update counts and sort children in the correct order.

Source

pub fn own_size(&self, apparent: bool) -> u64

This entry’s own size under apparent: its length, or its allocated blocks. Symbolic links count as zero, as in a scan.

Source

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

Recompute every size below and including this node from the entries’ own lengths and blocks, then re-sort children by size.

A multiply linked file (one with an inode) counts once, at its first occurrence in the current child order, unless count_hard_links. Iterative, so deep trees cannot exhaust the stack.

Trait Implementations§

Source§

impl Clone for FileNode

Source§

fn clone(&self) -> FileNode

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 FileNode

Source§

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

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

impl<'de> Deserialize<'de> for FileNode

Source§

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

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

impl Drop for FileNode

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Serialize for FileNode

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.