Skip to main content

Greplm

Struct Greplm 

Source
pub struct Greplm { /* private fields */ }
Expand description

A handle to a greplm project (a directory and its .greplm index).

Implementations§

Source§

impl Greplm

Source

pub fn open(root: impl AsRef<Path>) -> Result<Greplm>

Open (and lazily initialize) the index for root.

Source

pub fn discover(start: impl AsRef<Path>) -> Result<Greplm>

Find the nearest ancestor of start containing a .greplm directory, falling back to start itself if none is found.

Source

pub fn root(&self) -> &Path

Source

pub fn config(&self) -> &Config

Source

pub fn ensure_initialized(&self) -> Result<()>

Ensure the .greplm directory exists with a default config and gitignore.

Source

pub fn index(&self, force: bool) -> Result<IndexStats>

Build or refresh the index.

Source

pub fn ensure_indexed(&self) -> Result<bool>

Ensure a usable, current-schema index exists, building it if absent, empty, or left unreadable by an on-disk format change. Returns true if a (re)build happened. This is the self-healing entry point for query paths: a fresh checkout or a post-upgrade stale index transparently builds instead of erroring with “run greplm index first”.

Cheap when a good index already exists (one manifest read). The actual rebuild-on-corrupt logic lives in Indexer::index_incremental, which falls back to a full rebuild on an unreadable/outdated manifest.

Source

pub fn is_dirty(&self) -> Result<bool>

Stat-only freshness probe: does any file on disk differ from what the index recorded (new, modified by size/mtime, or deleted)? No content hashing and no reads — just the same cheap pre-check the incremental indexer uses. The daemon calls this to guarantee read-after-write consistency: if dirty, it reindexes before answering.

Source

pub fn compact(&self) -> Result<IndexStats>

Merge all segments into a single compact segment, dropping tombstoned documents. Falls back to a full rebuild if the merge cannot proceed.

Source

pub fn searcher(&self) -> Result<Searcher>

Open a searcher over the current index.

Source

pub fn searcher_reusing(&self, prev: &Searcher) -> Result<Searcher>

Open a searcher over the current index, sharing unchanged segments and the warm content cache with prev (see Searcher::open_reusing). The daemon uses this so a hot-swap after an incremental index re-reads only what actually changed instead of re-parsing every segment.

Source

pub fn search_or_grep(&self, query: &SearchQuery) -> Result<Vec<SearchHit>>

Content search that always returns results: it queries the index, and if the index is missing or errors, transparently falls back to an index-free walk+scan (grep parity). The fallback is logged at WARN.

Source

pub fn status(&self) -> Result<Status>

Report index status.

Source

pub fn clean(&self) -> Result<()>

Remove the entire .greplm directory.

Source

pub fn watch<F: FnMut(&IndexStats)>( &self, debounce: Duration, on_change: F, ) -> Result<()>

Watch the project tree and re-index incrementally on changes.

on_change is called after each successful incremental update. This call blocks until an error occurs or the watcher is dropped.

Source

pub fn socket_path(&self) -> PathBuf

Path to the daemon’s Unix socket for this project.

Source

pub fn record_savings( &self, kind: &str, files: &BTreeSet<String>, returned_chars: u64, results: u64, )

Record a query’s token savings (grep+read baseline vs. returned payload). Best-effort; never fails a query.

Source

pub fn savings_report(&self) -> SavingsReport

Aggregate the recorded token-savings log.

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