Skip to main content

VirtualTree

Struct VirtualTree 

Source
pub struct VirtualTree { /* private fields */ }
Expand description

An in-memory virtual filesystem tree: directories derived from path components and files mapped to track ids. Inodes are stable for the lifetime of the tree.

Implementations§

Source§

impl VirtualTree

Source

pub const ROOT: u64 = 1

Source

pub fn build(entries: &[(i64, String)]) -> VirtualTree

Source

pub fn build_with( entries: &[(i64, String)], alloc: &mut InodeAllocator, ) -> VirtualTree

Case-sensitive build (the default everywhere except a folded mount). Inodes are assigned via alloc (keyed by rendered path), stable across rebuilds that reuse the same allocator.

Source

pub fn build_with_ci( entries: &[(i64, String)], alloc: &mut InodeAllocator, case_insensitive: bool, ) -> VirtualTree

Build with explicit case-folding. With case_insensitive, names fold: case-variant directories merge, case-variant files disambiguate.

Source

pub fn equiv(&self, other: &VirtualTree) -> bool

Structural equality for the equivalence oracle: identical track→inode map, node set, AND children maps. Delegates to the derived PartialEq so adding a field to VirtualTree can never silently weaken the oracle. See SP2 Testing item 1.

Source

pub fn node(&self, inode: u64) -> Option<&Node>

Source

pub fn parent(&self, inode: u64) -> Option<u64>

The parent inode of inode (root’s parent is itself), or None if inode is unknown. Used by the FUSE layer to emit .. directory entries.

Source

pub fn children(&self, inode: u64) -> Option<&OrdMap<String, u64>>

Source

pub fn lookup(&self, parent: u64, name: &str) -> Option<u64>

Source

pub fn is_dir(&self, inode: u64) -> bool

Source

pub fn entry_counts(&self) -> (u64, u64)

(files, directories) currently materialized: files are tracks, dirs are every directory node except the synthetic root. O(nodes), no path rendering — cheap enough to surface on mount (#522).

Source

pub fn track_id(&self, inode: u64) -> Option<i64>

Source

pub fn inode_of_track(&self, track_id: i64) -> Option<u64>

The inode of the file node serving track_id, if present.

Source

pub fn track_ids(&self) -> HashSet<i64>

All track ids referenced by file nodes (used to prune stale cache entries).

Source

pub fn node_count(&self) -> usize

Number of live inodes (telemetry: virtual-tree footprint, #394).

Source

pub fn children_by_rendered(&self, dir: u64, rendered: &str) -> Vec<u64>

Inodes of dir’s direct children whose pre-disambiguation name is rendered.

Source

pub fn introducing_id(&self, ino: u64) -> i64

Minimum descendant track id under ino (a file’s own id; a dir’s min over files). Returns i64::MAX if ino has no file descendants (empty subtree).

Source

pub fn remove_track( &mut self, track_id: i64, _alloc: &mut InodeAllocator, ) -> Option<(u64, Option<(String, String)>)>

Remove the file node for track_id and prune now-empty ancestor dirs. Returns the inode of the nearest surviving ancestor directory plus, when dirs were pruned, the (name, rendered_name) of the topmost pruned dir (the direct child the survivor lost — for collision-gated dirty bookkeeping).

Trait Implementations§

Source§

impl Clone for VirtualTree

Source§

fn clone(&self) -> VirtualTree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for VirtualTree

Source§

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

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

impl Eq for VirtualTree

Source§

impl PartialEq for VirtualTree

Source§

fn eq(&self, other: &VirtualTree) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for VirtualTree

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.