Skip to main content

FileTree

Struct FileTree 

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

The explorer tree: structure, selection, and navigation. All pure logic.

Implementations§

Source§

impl FileTree

Source

pub fn new( root_path: impl Into<PathBuf>, display_name: impl Into<OsString>, ) -> Self

Build a tree containing just the root directory, collapsed and unloaded.

Source

pub fn root(&self) -> NodeId

Source

pub fn selected(&self) -> NodeId

Source

pub fn node(&self, id: NodeId) -> Option<&Node>

Source

pub fn path_of(&self, id: NodeId) -> Option<&Path>

Source

pub fn begin_load(&mut self, id: NodeId) -> Option<PathBuf>

Mark a directory as awaiting a read and hand back the path the worker should list. Returns None when nothing needs reading — not a directory, already loaded, or a read is already in flight — so callers never issue duplicate work.

Source

pub fn expand(&mut self, id: NodeId) -> Option<PathBuf>

Expand a directory. Returns a path if the contents still need to be read.

Source

pub fn collapse(&mut self, id: NodeId)

Source

pub fn toggle(&mut self, id: NodeId) -> Option<PathBuf>

Expand if collapsed, collapse if expanded. Returns a path needing a read.

Source

pub fn set_error(&mut self, id: NodeId, error: FsError)

Record a failed directory read against its node, leaving siblings untouched.

Source

pub fn set_children(&mut self, id: NodeId, entries: Vec<DirEntryInfo>)

Absorb a directory listing, reconciling against whatever is already there.

Entries matched by name keep their NodeId, their expanded flag, and their already-loaded descendants. Vanished entries are tombstoned. This is what makes a watch-triggered re-read non-destructive to the user’s view (ADR-0005 §5) — re-reading a level is far simpler than patching the tree from event deltas, and this reconciliation is what makes that affordable.

Source

pub fn visible_rows(&self) -> Vec<Row>

The expanded tree flattened into render order (depth-first, parents before children).

Source

pub fn find_by_path(&self, path: &Path) -> Option<NodeId>

Find a live node by its path. Linear, but only ever over loaded nodes, which is bounded by what the user has actually expanded.

Source

pub fn dirs_to_refresh(&self, changed: &[PathBuf]) -> Vec<NodeId>

Given paths that changed on disk, decide which loaded directories to re-read.

A change to /r/src/main.rs means re-reading /r/src; a change to /r/src itself means the same. Directories we have never loaded are skipped — there is nothing to refresh, and expanding them later will read them anyway. The result is deduplicated so a burst of edits in one directory costs one read (ADR-0005 §5).

Source

pub fn loaded_directories(&self) -> Vec<(NodeId, PathBuf)>

Every directory whose contents are currently materialized, expanded or not. Configuration reload uses this to reapply exclusion rules immediately without walking any directory the user never opened.

Source

pub fn refresh(&mut self, id: NodeId) -> Option<PathBuf>

Queue a re-read of an already-loaded directory, keeping the current contents visible until the new listing arrives. Returns the path to read.

Source

pub fn select(&mut self, id: NodeId)

Source

pub fn selected_row(&self) -> usize

Index of the selection within Self::visible_rows, for scrolling and highlight.

Source

pub fn select_next(&mut self)

Source

pub fn select_prev(&mut self)

Source

pub fn collapse_or_parent(&mut self)

Collapse the selection, or step to its parent when it is already collapsed — the conventional left-arrow behaviour in a tree.

Trait Implementations§

Source§

impl Clone for FileTree

Source§

fn clone(&self) -> FileTree

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 FileTree

Source§

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

Formats the value using the given formatter. Read more

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<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<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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.