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
impl WorkspaceIndex
Sourcepub fn start(roots: Vec<PathBuf>) -> Arc<Self> ⓘ
pub fn start(roots: Vec<PathBuf>) -> Arc<Self> ⓘ
Start scanning roots in the background with default options.
Sourcepub fn start_with(roots: Vec<PathBuf>, opts: IndexOptions) -> Arc<Self> ⓘ
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).
Sourcepub fn project_roots(working_dir: &Path) -> Vec<PathBuf>
pub fn project_roots(working_dir: &Path) -> Vec<PathBuf>
Roots of the index: [working_dir] plus every directory listed in
.whycodes/external_dirs_allowed.
Sourcepub fn primary_root(&self) -> Option<&Path>
pub fn primary_root(&self) -> Option<&Path>
The primary root (working directory). None if no roots were indexed.
Sourcepub fn status(&self) -> ScanStatus
pub fn status(&self) -> ScanStatus
Current scan progress.
Sourcepub fn wait_ready(&self, timeout: Duration) -> bool
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.
Sourcepub fn query_now(&self, pattern: &str, limit: usize) -> Vec<FileMatch>
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).
Sourcepub fn read_matches(&self, limit: usize) -> Vec<FileMatch>
pub fn read_matches(&self, limit: usize) -> Vec<FileMatch>
Non-blocking re-read of current matches (call when
take_results_dirty returns true).
Sourcepub fn take_results_dirty(&self) -> bool
pub fn take_results_dirty(&self) -> bool
One-shot check for freshly published matcher results.
Sourcepub fn rearm_fuzzy(&self)
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.
Sourcepub fn matching(&self) -> bool
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.
Sourcepub fn query(&self, pattern: &str, limit: usize) -> Vec<FileMatch>
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.
Sourcepub fn browse(&self, root: u16, rel_dir: &str) -> Vec<FileMatch>
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.
Sourcepub fn visit(&self, f: &mut dyn FnMut(&Entry) -> bool)
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.
Sourcepub fn visit_content_candidates(
&self,
search_root: &Path,
pattern: &str,
case_insensitive: bool,
f: &mut dyn FnMut(&Path, &str, u64) -> bool,
) -> Option<()>
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.
Trait Implementations§
Source§impl Debug for WorkspaceIndex
impl Debug for WorkspaceIndex
Source§impl Drop for WorkspaceIndex
impl Drop for WorkspaceIndex
Auto Trait Implementations§
impl !RefUnwindSafe for WorkspaceIndex
impl !UnwindSafe for WorkspaceIndex
impl Freeze for WorkspaceIndex
impl Send for WorkspaceIndex
impl Sync for WorkspaceIndex
impl Unpin for WorkspaceIndex
impl UnsafeUnpin for WorkspaceIndex
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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