Struct VfsEntry

Source
pub struct VfsEntry {
    parent: RwLock<Weak<VfsEntry>>,
    name: String,
    node: Arc<dyn VfsNode>,
    children: RwLock<BTreeMap<String, Weak<VfsEntry>>>,
}
Expand description

VfsEntry represents a node in the VFS path hierarchy (similar to Linux dentry)

This structure represents the VFS’s in-memory filesystem hierarchy graph. It serves as:

  • A “name” representation within a directory
  • A “link” that constructs parent-child relationships in the VFS graph
  • A cache for fast re-access to already resolved paths

VfsEntry is designed to be thread-safe and can be shared across threads.

Fields§

§parent: RwLock<Weak<VfsEntry>>

Weak reference to parent VfsEntry (prevents circular references)

§name: String

Name of this VfsEntry (e.g., “user”, “file.txt”)

§node: Arc<dyn VfsNode>

Reference to the corresponding file entity (VfsNode)

§children: RwLock<BTreeMap<String, Weak<VfsEntry>>>

Cache of child VfsEntries for fast lookup (using Weak to prevent memory leaks)

Implementations§

Source§

impl VfsEntry

Source

pub fn new( parent: Option<Weak<VfsEntry>>, name: String, node: Arc<dyn VfsNode>, ) -> Arc<Self>

Create a new VfsEntry

Source

pub fn name(&self) -> &String

Get the name of this entry

Source

pub fn node(&self) -> Arc<dyn VfsNode>

Get the VfsNode for this entry

Source

pub fn parent(&self) -> Option<Arc<VfsEntry>>

Get parent VfsEntry if it exists

Source

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

Source

pub fn add_child(self: &Arc<Self>, name: String, child: Arc<VfsEntry>)

Add a child to the cache

Source

pub fn get_child(&self, name: &String) -> Option<Arc<VfsEntry>>

Get a child from the cache

Source

pub fn remove_child(&self, name: &String) -> Option<Arc<VfsEntry>>

Remove a child from the cache

Source

pub fn cleanup_cache(&self)

Clean up expired weak references in the cache

Trait Implementations§

Source§

impl Clone for VfsEntry

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VfsEntry

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for VfsEntry

§

impl !RefUnwindSafe for VfsEntry

§

impl Send for VfsEntry

§

impl Sync for VfsEntry

§

impl Unpin for VfsEntry

§

impl !UnwindSafe for VfsEntry

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> CloneToUninit for T
where T: Clone,

§

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
§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

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.