pub struct Index { /* private fields */ }Implementations§
Source§impl Index
impl Index
Sourcepub fn file_count(&self) -> usize
pub fn file_count(&self) -> usize
Number of live (non-deleted) files known to the index.
pub fn trigram_count(&self) -> usize
Sourcepub fn build(root: impl AsRef<Path>) -> Index
pub fn build(root: impl AsRef<Path>) -> Index
Build an index over root, honoring the same ignore rules ripgrep uses by default.
Sourcepub fn from_paths(paths: &[PathBuf], progress: &AtomicUsize) -> Index
pub fn from_paths(paths: &[PathBuf], progress: &AtomicUsize) -> Index
Build an index from an already-walked path set, bumping progress once per file processed so
a watcher can show a climbing count during a cold build.
Sourcepub fn apply_changes(&mut self, changed: &[PathBuf], removed: &[PathBuf])
pub fn apply_changes(&mut self, changed: &[PathBuf], removed: &[PathBuf])
Apply a set of changed and removed paths to the resident index (incremental update).
Sourcepub fn reconcile(&mut self, root: impl AsRef<Path>) -> usize
pub fn reconcile(&mut self, root: impl AsRef<Path>) -> usize
Reconcile the index against the current tree by (size, mtime): index new/changed files and
tombstone vanished ones. Used at daemon startup to catch changes made while it was down.
Returns the number of files re-indexed plus removed.
Sourcepub fn candidates(&self, query: &Query) -> Vec<&Path>
pub fn candidates(&self, query: &Query) -> Vec<&Path>
Resolve a trigram query to candidate files (a sound superset of the real matches). A fallback query (no usable trigram) simply makes every live file a candidate — there is no separate “scan the tree” path; ripgrep then confirms over whatever this returns.
Sourcepub fn find(
&self,
needle: &str,
after: Option<&str>,
limit: usize,
) -> (Vec<&Path>, usize, usize)
pub fn find( &self, needle: &str, after: Option<&str>, limit: usize, ) -> (Vec<&Path>, usize, usize)
File/dir name lookup (fd/find-style): live paths whose string contains needle. Returns the
keyset page (paths whose string is strictly greater than after, capped at limit), the total
number of matches, and start (matches skipped before this page) so callers can report an
honest “X-Y of total”. Sorted by path string — the same order callers keyset on — so paging is
deterministic and never skips or repeats.
Sourcepub fn memory_bytes(&self) -> u64
pub fn memory_bytes(&self) -> u64
Approximate resident size of the posting lists (serialized roaring bytes), for status.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Index
impl RefUnwindSafe for Index
impl Send for Index
impl Sync for Index
impl Unpin for Index
impl UnsafeUnpin for Index
impl UnwindSafe for Index
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> 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