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