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
impl VirtualTree
pub const ROOT: u64 = 1
pub fn build(entries: &[(i64, String)]) -> VirtualTree
Sourcepub fn build_with(
entries: &[(i64, String)],
alloc: &mut InodeAllocator,
) -> VirtualTree
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.
Sourcepub fn build_with_ci(
entries: &[(i64, String)],
alloc: &mut InodeAllocator,
case_insensitive: bool,
) -> VirtualTree
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.
Sourcepub fn equiv(&self, other: &VirtualTree) -> bool
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.
pub fn node(&self, inode: u64) -> Option<&Node>
Sourcepub fn parent(&self, inode: u64) -> Option<u64>
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.
pub fn children(&self, inode: u64) -> Option<&OrdMap<String, u64>>
pub fn lookup(&self, parent: u64, name: &str) -> Option<u64>
pub fn is_dir(&self, inode: u64) -> bool
Sourcepub fn entry_counts(&self) -> (u64, u64)
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).
pub fn track_id(&self, inode: u64) -> Option<i64>
Sourcepub fn inode_of_track(&self, track_id: i64) -> Option<u64>
pub fn inode_of_track(&self, track_id: i64) -> Option<u64>
The inode of the file node serving track_id, if present.
Sourcepub fn track_ids(&self) -> HashSet<i64>
pub fn track_ids(&self) -> HashSet<i64>
All track ids referenced by file nodes (used to prune stale cache entries).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of live inodes (telemetry: virtual-tree footprint, #394).
Sourcepub fn children_by_rendered(&self, dir: u64, rendered: &str) -> Vec<u64>
pub fn children_by_rendered(&self, dir: u64, rendered: &str) -> Vec<u64>
Inodes of dir’s direct children whose pre-disambiguation name is rendered.
Sourcepub fn introducing_id(&self, ino: u64) -> i64
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).
Sourcepub fn remove_track(
&mut self,
track_id: i64,
_alloc: &mut InodeAllocator,
) -> Option<(u64, Option<(String, String)>)>
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
impl Clone for VirtualTree
Source§fn clone(&self) -> VirtualTree
fn clone(&self) -> VirtualTree
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VirtualTree
impl Debug for VirtualTree
impl Eq for VirtualTree
Source§impl PartialEq for VirtualTree
impl PartialEq for VirtualTree
Source§fn eq(&self, other: &VirtualTree) -> bool
fn eq(&self, other: &VirtualTree) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for VirtualTree
Auto Trait Implementations§
impl Freeze for VirtualTree
impl RefUnwindSafe for VirtualTree
impl Send for VirtualTree
impl Sync for VirtualTree
impl Unpin for VirtualTree
impl UnsafeUnpin for VirtualTree
impl UnwindSafe for VirtualTree
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.