pub struct SharedFilePicker(/* private fields */);Expand description
Thread-safe shared handle to the FilePicker instance.
This accumulates only asynchronous non-blocking operations against the
file picker: creating, triggering various rescans and so on.
For blocking access use internal picker via .read() or .write()
let shared_picker = SharedFilePicker::default();
if let Some(picker) = shared_picker.read()?.as_ref() {
let files = picker.fuzzy_search(&query, options);
println!("Found {} files", files.len());
} else {
println!("Picker not initialized");
}Implementations§
pub fn read(&self) -> Result<RwLockReadGuard<'_, Option<FilePicker>>, Error>
pub fn write(&self) -> Result<RwLockWriteGuard<'_, Option<FilePicker>>, Error>
Sourcepub fn cancel(&self)
pub fn cancel(&self)
Signal the background scan to cancel. Non-blocking: post-scan threads check this flag and bail out at their next cancellation point.
Sourcepub fn need_complex_rebuild(&self) -> bool
pub fn need_complex_rebuild(&self) -> bool
Return true if this is an instance of the picker that requires a complicated post-scan
indexing/cache warmup job. The indexing is not crazy but it takes time.
Sourcepub fn wait_for_scan(&self, timeout: Duration) -> bool
pub fn wait_for_scan(&self, timeout: Duration) -> bool
Block until the background filesystem scan finishes.
Returns true if scan completed, false on timeout.
Sourcepub fn wait_for_watcher(&self, timeout: Duration) -> bool
pub fn wait_for_watcher(&self, timeout: Duration) -> bool
Block until the background file watcher is ready.
Returns true if watcher ready, false on timeout.
Sourcepub fn wait_for_indexing_complete(&self, timeout: Duration) -> bool
pub fn wait_for_indexing_complete(&self, timeout: Duration) -> bool
Blocks until both the filesystem walk and post-scan indexing are done. Returns true once scanning=false AND post_scan_indexing_active=false.
Sourcepub fn trigger_full_rescan_async(
&self,
shared_frecency: &SharedFrecency,
) -> Result<(), Error>
pub fn trigger_full_rescan_async( &self, shared_frecency: &SharedFrecency, ) -> Result<(), Error>
Trigger a full filesystem rescan without blocking the caller. Performs a safe async rescan. Guarantees only single active rescan per picker. If many rescans requested the last one guaranteed to be finished.
Sourcepub fn rescan_stats(&self) -> RescanStats
pub fn rescan_stats(&self) -> RescanStats
Returns admitted and throttled rescan requests by reason. Counters start at picker creation or the last reset.
pub fn reset_rescan_stats(&self)
Sourcepub fn watch(
&self,
pattern: &str,
options: WatchOptions,
callback: impl Fn(WatchId, &[WatchEvent]) + Send + Sync + 'static,
) -> Result<WatchId, Error>
pub fn watch( &self, pattern: &str, options: WatchOptions, callback: impl Fn(WatchId, &[WatchEvent]) + Send + Sync + 'static, ) -> Result<WatchId, Error>
Subscribe to filesystem changes matching pattern.
Patterns may be base-relative globs (./ works), exact paths inside the indexed tree, or existing directories. An empty pattern watches the whole tree.
Events are debounced and submitted in batches per 100-ms window at most 128 events. Gitignored and other ignored files are never triggering watcher.
Sourcepub fn unwatch(&self, id: WatchId) -> bool
pub fn unwatch(&self, id: WatchId) -> bool
Remove a watch subscription. Returns true if the id was active.
Sourcepub fn is_watch_active(&self, id: WatchId) -> bool
pub fn is_watch_active(&self, id: WatchId) -> bool
Return whether a watch subscription is active.
Sourcepub fn shutdown_watches(&self)
pub fn shutdown_watches(&self)
Remove every subscription without waiting for an executing callback.
Sourcepub fn shutdown_watches_and_wait(&self)
pub fn shutdown_watches_and_wait(&self)
Remove every subscription and wait for an executing callback. When called by that callback, it does not wait on itself.
Sourcepub fn refresh_git_status(
&self,
shared_frecency: &SharedFrecency,
) -> Result<usize, Error>
pub fn refresh_git_status( &self, shared_frecency: &SharedFrecency, ) -> Result<usize, Error>
Refresh git statuses for all indexed files
Sourcepub fn update_git_status_for_paths(
&self,
paths: &[PathBuf],
shared_frecency: &SharedFrecency,
) -> Result<(), Error>
pub fn update_git_status_for_paths( &self, paths: &[PathBuf], shared_frecency: &SharedFrecency, ) -> Result<(), Error>
Recompute and apply git status for a specific set of paths.
Trait Implementations§
Source§fn clone(&self) -> SharedFilePicker
fn clone(&self) -> SharedFilePicker
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§fn default() -> SharedFilePicker
fn default() -> SharedFilePicker
Auto Trait Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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