Skip to main content

Index

Struct Index 

Source
pub struct Index { /* private fields */ }

Implementations§

Source§

impl Index

Source

pub fn file_count(&self) -> usize

Number of live (non-deleted) files known to the index.

Source

pub fn trigram_count(&self) -> usize

Source

pub fn build(root: impl AsRef<Path>) -> Index

Build an index over root, honoring the same ignore rules ripgrep uses by default.

Source

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.

Source

pub fn apply_changes(&mut self, changed: &[PathBuf], removed: &[PathBuf])

Apply a set of changed and removed paths to the resident index (incremental update).

Source

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.

Source

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.

Source

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.

Source

pub fn memory_bytes(&self) -> u64

Approximate resident size of the posting lists (serialized roaring bytes), for status.

Source

pub fn save(&self, path: impl AsRef<Path>) -> Result<()>

Serialize the index to path (atomic via temp file + rename).

Source

pub fn load(path: impl AsRef<Path>) -> Result<Index>

Load an index snapshot from path. Errors (incl. version mismatch) signal “rebuild”.

Trait Implementations§

Source§

impl Default for Index

Source§

fn default() -> Index

Returns the “default value” for a type. Read more

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