pub struct FileNode {
pub id: NodeId,
pub name: CompactString,
pub kind: NodeKind,
pub size: u64,
pub blocks: u64,
pub timestamps: Timestamps,
pub inode: Option<InodeInfo>,
pub content_hash: Option<ContentHash>,
pub git_status: Option<GitStatus>,
pub children: Vec<FileNode>,
}Expand description
A single file or directory in the tree.
Fields§
§id: NodeIdUnique identifier for this node.
name: CompactStringFile/directory name (not full path).
kind: NodeKindNode type and associated metadata.
size: u64Size in bytes (aggregate for directories).
blocks: u64Disk blocks actually used.
timestamps: TimestampsFile metadata timestamps.
inode: Option<InodeInfo>Inode info for hardlink detection.
content_hash: Option<ContentHash>Content hash (computed on demand). Stored inline — 32 bytes, no heap allocation.
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
impl FileNode
Sourcepub fn new_file(
id: NodeId,
name: impl Into<CompactString>,
size: u64,
blocks: u64,
timestamps: Timestamps,
executable: bool,
) -> Self
pub fn new_file( id: NodeId, name: impl Into<CompactString>, size: u64, blocks: u64, timestamps: Timestamps, executable: bool, ) -> Self
Create a new file node.
Sourcepub fn new_directory(
id: NodeId,
name: impl Into<CompactString>,
timestamps: Timestamps,
) -> Self
pub fn new_directory( id: NodeId, name: impl Into<CompactString>, timestamps: Timestamps, ) -> Self
Create a new directory node.
Sourcepub fn child_count(&self) -> usize
pub fn child_count(&self) -> usize
Get the number of direct children.
Sourcepub fn file_count(&self) -> u64
pub fn file_count(&self) -> u64
Get file count for directories (includes files, symlinks, and other entries), 1 for files/symlinks/other.
Sourcepub fn sort_children_by_size(&mut self)
pub fn sort_children_by_size(&mut self)
Sort children by size in descending order, with deterministic secondary sort by name.
Must be called after update_counts for correct directory sizes.
Sourcepub fn update_counts(&mut self)
pub fn update_counts(&mut self)
Recursively update directory file/dir counts based on children (post-order traversal).
This recurses into all children first, then aggregates counts upward. Symlinks and Other entries are counted in the file count.