Struct TmpNode

Source
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

Source

pub fn new_file(name: String, file_id: u64) -> Self

Create a new regular file node

Source

pub fn new_directory(name: String, file_id: u64) -> Self

Create a new directory node

Source

pub fn new_device(name: String, file_type: FileType, file_id: u64) -> Self

Create a new device file node

Create a new symbolic link node

Source

pub fn set_filesystem(&self, fs: Weak<dyn FileSystemOperations>)

Set the filesystem reference for this node

Source

pub fn update_size(&self, new_size: u64)

Update file size in metadata

Source

pub fn set_parent(&self, parent: Weak<TmpNode>)

Set parent reference for this node

Source

pub fn is_filesystem_root(&self) -> bool

Check if this node is the root of the filesystem

Source

pub fn name(&self) -> String

Get the file name

Source

pub fn file_type(&self) -> FileType

Get the file type

Source

pub fn filesystem(&self) -> Option<Weak<dyn FileSystemOperations>>

Get the filesystem reference

Source

pub fn parent(&self) -> Option<Weak<TmpNode>>

Get the parent node

Trait Implementations§

Source§

impl Debug for TmpNode

Source§

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

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

impl VfsNode for TmpNode

Source§

fn id(&self) -> u64

Returns the unique identifier in the filesystem
Source§

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>

Get metadata for this node
Source§

fn as_any(&self) -> &dyn Any

Helper for downcasting
Read the target of a symbolic link (returns error if not a symlink)
Source§

fn file_type(&self) -> Result<FileType, FileSystemError>

Get the file type of this node
Source§

fn is_directory(&self) -> Result<bool, FileSystemError>

Returns true if this node is a directory
Returns true if this node is a symbolic link

Auto Trait Implementations§

§

impl !Freeze for TmpNode

§

impl !RefUnwindSafe for TmpNode

§

impl Send for TmpNode

§

impl Sync for TmpNode

§

impl Unpin for TmpNode

§

impl !UnwindSafe for TmpNode

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.