Skip to main content

FilePicker

Struct FilePicker 

Source
pub struct FilePicker {
    pub mode: FFFMode,
    pub base_path: PathBuf,
    pub is_scanning: Arc<AtomicBool>,
    /* private fields */
}

Fields§

§mode: FFFMode§base_path: PathBuf§is_scanning: Arc<AtomicBool>

Implementations§

Source§

impl FilePicker

Source

pub fn base_path(&self) -> &Path

Source

pub fn need_enable_mmap_cache(&self) -> bool

Source

pub fn need_enable_content_indexing(&self) -> bool

Source

pub fn need_watch(&self) -> bool

Source

pub fn mode(&self) -> FFFMode

Source

pub fn cache_budget(&self) -> &ContentCacheBudget

Source

pub fn bigram_index(&self) -> Option<&BigramFilter>

Source

pub fn bigram_overlay(&self) -> Option<&RwLock<BigramOverlay>>

Source

pub fn get_file_mut(&mut self, index: usize) -> Option<&mut FileItem>

Source

pub fn set_bigram_index(&mut self, index: BigramFilter, overlay: BigramOverlay)

Source

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

Source

pub fn get_files(&self) -> &[FileItem]

Get all indexed files sorted by path. Note: Files are stored sorted by PATH for efficient insert/remove. For frecency-sorted results, use search() which sorts matched results.

Source

pub fn get_overflow_files(&self) -> &[FileItem]

Source

pub fn get_dirs(&self) -> &[DirItem]

Get the directory table (sorted by path).

Source

pub fn arena_bytes(&self) -> (usize, usize, usize)

Actual heap bytes used: (chunked_path_store, 0, 0). The second element is 0 because leaked overflow stores aren’t tracked.

Source

pub fn extract_watch_dirs(&self) -> Vec<PathBuf>

Extracts all unique ancestor directories from the indexed file list. Uses the pre-built directory table when available (O(d) where d = unique dirs), falling back to the old traversal for overflow files.

Source

pub fn new(options: FilePickerOptions) -> Result<Self, Error>

Create a new FilePicker from options. Always prefer new_with_shared_state for the consumer application, use this only if you know what you are doing. This won’t spawn the backgraound watcher and won’t walk the file tree.

Source

pub fn new_with_shared_state( shared_picker: SharedPicker, shared_frecency: SharedFrecency, options: FilePickerOptions, ) -> Result<(), Error>

Create a picker, place it into the shared handle, and spawn background indexing + file-system watcher. This is the default entry point.

Source

pub fn collect_files(&mut self) -> Result<(), Error>

Synchronous filesystem scan — populates self with indexed files.

Use this when you need direct access to the picker without shared state:

let mut picker = FilePicker::new(options)?;
picker.collect_files()?;
// picker.get_files() is now populated
Source

pub fn spawn_background_watcher( &mut self, shared_picker: &SharedPicker, shared_frecency: &SharedFrecency, ) -> Result<(), Error>

Start the background file-system watcher.

The picker must already be placed into shared_picker (the watcher needs the shared handle to apply live updates). Call after collect_files or after an initial scan.

Perform fuzzy search on files with a pre-parsed query.

The query should be parsed using FFFQuery::parse() before calling this function. If a QueryTracker is provided, the search will automatically look up the last selected file for this query and apply combo-boost scoring.

Source

pub fn fuzzy_search_directories<'q>( &self, query: &'q FFFQuery<'q>, options: FuzzySearchOptions<'q>, ) -> DirSearchResult<'_>

Perform fuzzy search on indexed directories.

Returns directories ranked by fuzzy match quality + frecency.

Source

pub fn fuzzy_search_mixed<'q>( &self, query: &'q FFFQuery<'q>, query_tracker: Option<&QueryTracker>, options: FuzzySearchOptions<'q>, ) -> MixedSearchResult<'_>

Perform a mixed fuzzy search across both files and directories.

Returns a single flat list where files and directories are interleaved by total score in descending order.

If the raw query ends with a path separator (/), only directories are searched — files are skipped entirely. The caller should parse the query with DirSearchConfig so that trailing / is kept as fuzzy text instead of becoming a PathSegment constraint.

Source

pub fn grep( &self, query: &FFFQuery<'_>, options: &GrepSearchOptions, ) -> GrepResult<'_>

Perform a live grep search across indexed files.

If options.abort_signal is set it overrides the picker’s internal cancellation flag, giving the caller full control over when to stop.

Source

pub fn multi_grep( &self, patterns: &[&str], constraints: &[Constraint<'_>], options: &GrepSearchOptions, ) -> GrepResult<'_>

Multi-pattern grep search across indexed files.

Source

pub fn grep_without_overlay( &self, query: &FFFQuery<'_>, options: &GrepSearchOptions, ) -> GrepResult<'_>

Like grep but ignores the bigram overlay.

Source

pub fn get_scan_progress(&self) -> ScanProgress

Source

pub fn update_git_statuses( &mut self, status_cache: GitStatusCache, shared_frecency: &SharedFrecency, ) -> Result<(), Error>

Update git statuses for files, using the provided shared frecency tracker.

Source

pub fn update_single_file_frecency( &mut self, file_path: impl AsRef<Path>, frecency_tracker: &FrecencyTracker, ) -> Result<(), Error>

Source

pub fn get_file_by_path(&self, path: impl AsRef<Path>) -> Option<&FileItem>

Source

pub fn get_mut_file_by_path( &mut self, path: impl AsRef<Path>, ) -> Option<&mut FileItem>

Source

pub fn add_file_sorted(&mut self, file: FileItem) -> Option<&FileItem>

Add a file to the picker’s files in sorted order (used by background watcher)

Source

pub fn on_create_or_modify( &mut self, path: impl AsRef<Path> + Debug, ) -> Option<&FileItem>

Source

pub fn remove_file_by_path(&mut self, path: impl AsRef<Path>) -> bool

Tombstone a file instead of removing it, keeping base indices stable.

Source

pub fn remove_all_files_in_dir(&mut self, dir: impl AsRef<Path>) -> usize

Source

pub fn cancel(&self)

Use this to prevent any substantial background threads from acquiring the locks

Source

pub fn stop_background_monitor(&mut self)

Source

pub fn trigger_rescan( &mut self, shared_frecency: &SharedFrecency, ) -> Result<(), Error>

Source

pub fn is_scan_active(&self) -> bool

Quick way to check if scan is going without acquiring a lock for Self::get_scan_progress

Source

pub fn scan_signal(&self) -> Arc<AtomicBool>

Return a clone of the scanning flag so callers can poll it without holding a lock on the picker.

Source

pub fn watcher_signal(&self) -> Arc<AtomicBool>

Return a clone of the watcher-ready flag so callers can poll it without holding a lock on the picker.

Trait Implementations§

Source§

impl Debug for FilePicker

Source§

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

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

impl FFFStringStorage for &FilePicker

Source§

fn arena_for(&self, file: &FileItem) -> ArenaPtr

Resolve the arena for a FileItem (handles base vs overflow split).
Source§

fn base_arena(&self) -> ArenaPtr

The base arena (scan-time paths).
Source§

fn overflow_arena(&self) -> ArenaPtr

The overflow arena (paths added after the last full scan).

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