pub struct TmpNode {
name: RwLock<String>,
file_type: RwLock<FileType>,
metadata: RwLock<FileMetadata>,
content: RwLock<Vec<u8>>,
children: RwLock<BTreeMap<String, Arc<dyn VfsNode>>>,
parent: RwLock<Option<Weak<TmpNode>>>,
filesystem: RwLock<Option<Weak<dyn FileSystemOperations>>>,
}
Expand description
TmpNode represents a file, directory, or device node in TmpFS.
Each node contains metadata, content (for files), children (for directories), and references to its parent and filesystem. All fields are protected by locks for thread safety.
Fields§
§name: RwLock<String>
File name
file_type: RwLock<FileType>
File type
metadata: RwLock<FileMetadata>
File metadata
content: RwLock<Vec<u8>>
File content (for regular files)
children: RwLock<BTreeMap<String, Arc<dyn VfsNode>>>
Child nodes (for directories)
parent: RwLock<Option<Weak<TmpNode>>>
Parent node (weak reference to avoid cycles)
filesystem: RwLock<Option<Weak<dyn FileSystemOperations>>>
Reference to filesystem (Weak
Implementations§
Source§impl TmpNode
impl TmpNode
Sourcepub fn new_directory(name: String, file_id: u64) -> Self
pub fn new_directory(name: String, file_id: u64) -> Self
Create a new directory node
Sourcepub fn new_device(name: String, file_type: FileType, file_id: u64) -> Self
pub fn new_device(name: String, file_type: FileType, file_id: u64) -> Self
Create a new device file node
Sourcepub fn new_symlink(name: String, target: String, file_id: u64) -> Self
pub fn new_symlink(name: String, target: String, file_id: u64) -> Self
Create a new symbolic link node
Sourcepub fn set_filesystem(&self, fs: Weak<dyn FileSystemOperations>)
pub fn set_filesystem(&self, fs: Weak<dyn FileSystemOperations>)
Set the filesystem reference for this node
Sourcepub fn update_size(&self, new_size: u64)
pub fn update_size(&self, new_size: u64)
Update file size in metadata
Sourcepub fn set_parent(&self, parent: Weak<TmpNode>)
pub fn set_parent(&self, parent: Weak<TmpNode>)
Set parent reference for this node
Sourcepub fn is_filesystem_root(&self) -> bool
pub fn is_filesystem_root(&self) -> bool
Check if this node is the root of the filesystem
Sourcepub fn filesystem(&self) -> Option<Weak<dyn FileSystemOperations>>
pub fn filesystem(&self) -> Option<Weak<dyn FileSystemOperations>>
Get the filesystem reference
Trait Implementations§
Source§impl VfsNode for TmpNode
impl VfsNode for TmpNode
Source§fn filesystem(&self) -> Option<Weak<dyn FileSystemOperations>>
fn filesystem(&self) -> Option<Weak<dyn FileSystemOperations>>
Returns a (Weak) reference to the filesystem this node belongs to
Source§fn metadata(&self) -> Result<FileMetadata, FileSystemError>
fn metadata(&self) -> Result<FileMetadata, FileSystemError>
Get metadata for this node
Source§fn read_link(&self) -> Result<String, FileSystemError>
fn read_link(&self) -> Result<String, FileSystemError>
Read the target of a symbolic link (returns error if not a symlink)
Source§fn file_type(&self) -> Result<FileType, FileSystemError>
fn file_type(&self) -> Result<FileType, FileSystemError>
Get the file type of this node
Source§fn is_directory(&self) -> Result<bool, FileSystemError>
fn is_directory(&self) -> Result<bool, FileSystemError>
Returns true if this node is a directory
Source§fn is_symlink(&self) -> Result<bool, FileSystemError>
fn is_symlink(&self) -> Result<bool, FileSystemError>
Returns true if this node is a symbolic link