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,
) -> FileNode
pub fn new_file( id: NodeId, name: impl Into<CompactString>, size: u64, blocks: u64, timestamps: Timestamps, executable: bool, ) -> FileNode
Create a new file node.
Sourcepub fn new_directory(
id: NodeId,
name: impl Into<CompactString>,
timestamps: Timestamps,
) -> FileNode
pub fn new_directory( id: NodeId, name: impl Into<CompactString>, timestamps: Timestamps, ) -> FileNode
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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FileNode
impl<'de> Deserialize<'de> for FileNode
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileNode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<FileNode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for FileNode
impl Serialize for FileNode
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for FileNode
impl RefUnwindSafe for FileNode
impl Send for FileNode
impl Sync for FileNode
impl Unpin for FileNode
impl UnsafeUnpin for FileNode
impl UnwindSafe for FileNode
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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