Skip to main content

WorkspaceIndex

Struct WorkspaceIndex 

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

Resident workspace file index. Clone-handle via Arc.

The background scanner thread is owned by this handle: dropping the last handle cancels the walk and joins the thread (bounded — the walk checks the cancel flag per entry and the command loop wakes every 250 ms).

Implementations§

Source§

impl WorkspaceIndex

Source

pub fn start(roots: Vec<PathBuf>) -> Arc<Self> ⓘ

Start scanning roots in the background with default options.

Source

pub fn start_with(roots: Vec<PathBuf>, opts: IndexOptions) -> Arc<Self> ⓘ

Like start with explicit options.

Roots are canonicalized; missing/non-dir roots and roots nested inside an earlier root are dropped (they would duplicate entries).

Source

pub fn project_roots(working_dir: &Path) -> Vec<PathBuf>

Roots of the index: [working_dir] plus every directory listed in .whycodes/external_dirs_allowed.

Source

pub fn roots(&self) -> &[PathBuf]

The canonicalized roots being indexed.

Source

pub fn primary_root(&self) -> Option<&Path>

The primary root (working directory). None if no roots were indexed.

Source

pub fn status(&self) -> ScanStatus

Current scan progress.

Source

pub fn is_ready(&self) -> bool

True once the initial walk has finished.

Source

pub fn len(&self) -> usize

Total indexed entries across roots.

Source

pub fn is_empty(&self) -> bool

True when no entries are indexed (yet).

Source

pub fn wait_ready(&self, timeout: Duration) -> bool

Block until the index is ready or timeout elapses. For tests and one-shot CLI paths; the TUI should poll status.

Source

pub fn query_now(&self, pattern: &str, limit: usize) -> Vec<FileMatch>

Non-blocking picker query: point every engine at pattern and read the matches currently available. Never waits on a rematch — fresh results are announced via [take_results_dirty] and picked up with read_matches.

Special forms: an empty pattern browses the top level of the primary root; a pattern ending in / browses that directory (store-backed, always synchronous).

Source

pub fn read_matches(&self, limit: usize) -> Vec<FileMatch>

Non-blocking re-read of current matches (call when take_results_dirty returns true).

Source

pub fn take_results_dirty(&self) -> bool

One-shot check for freshly published matcher results.

Source

pub fn rearm_fuzzy(&self)

Re-issue the last fuzzy query so workers publish a snapshot.

Needed when a tick(0) missed notify and the picker is idle on an empty list. See FuzzyEngine::rearm.

Source

pub fn matching(&self) -> bool

True while any engine is still matching or ingesting (walk running). UIs should keep polling on a short cadence while this holds.

Source

pub fn query(&self, pattern: &str, limit: usize) -> Vec<FileMatch>

Blocking fuzzy query (tests / one-shot callers). UIs should use query_now + the dirty flag instead.

Source

pub fn browse(&self, root: u16, rel_dir: &str) -> Vec<FileMatch>

Depth-1 listing of rel_dir inside root (dirs first, alpha). "" lists the top level. Filesystem-free — reads the store.

Source

pub fn visit(&self, f: &mut dyn FnMut(&Entry) -> bool)

Visit every primary-root entry without cloning (tools hot path). Return false from f to stop early.

Source

pub fn visit_content_candidates( &self, search_root: &Path, pattern: &str, case_insensitive: bool, f: &mut dyn FnMut(&Path, &str, u64) -> bool, ) -> Option<()>

Visit primary-root files under search_root that the content overlay cannot rule out for pattern. None means “do not prune” (regex / too short / Unicode case-fold / overlay not complete / path outside the primary root) — the caller should fall back to [visit].

f receives (abs, rel, size) with rel scoped to search_root, matching [visit] + tools visit_index. Return false to stop.

Source

pub fn entries(&self) -> Vec<Entry>

Clone of all primary-root entries (tools that need owned data).

Source

pub fn resolve(&self, m: &FileMatch) -> PathBuf

Absolute path for a match.

Source

pub fn rescan(&self)

Trigger a full background rescan (e.g. after branch switches).

Trait Implementations§

Source§

impl Debug for WorkspaceIndex

Source§

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

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

impl Drop for WorkspaceIndex

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more