pub struct Greplm { /* private fields */ }Expand description
A handle to a greplm project (a directory and its .greplm index).
Implementations§
Source§impl Greplm
impl Greplm
Sourcepub fn open(root: impl AsRef<Path>) -> Result<Greplm>
pub fn open(root: impl AsRef<Path>) -> Result<Greplm>
Open (and lazily initialize) the index for root.
Sourcepub fn discover(start: impl AsRef<Path>) -> Result<Greplm>
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.
pub fn root(&self) -> &Path
pub fn config(&self) -> &Config
Sourcepub fn ensure_initialized(&self) -> Result<()>
pub fn ensure_initialized(&self) -> Result<()>
Ensure the .greplm directory exists with a default config and gitignore.
Sourcepub fn index(&self, force: bool) -> Result<IndexStats>
pub fn index(&self, force: bool) -> Result<IndexStats>
Build or refresh the index.
Sourcepub fn compact(&self) -> Result<IndexStats>
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.
Sourcepub fn watch<F: FnMut(&IndexStats)>(
&self,
debounce: Duration,
on_change: F,
) -> Result<()>
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.
Sourcepub fn socket_path(&self) -> PathBuf
pub fn socket_path(&self) -> PathBuf
Path to the daemon’s Unix socket for this project.
Sourcepub fn record_savings(
&self,
kind: &str,
files: &BTreeSet<String>,
returned_chars: u64,
results: u64,
)
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.
Sourcepub fn savings_report(&self) -> SavingsReport
pub fn savings_report(&self) -> SavingsReport
Aggregate the recorded token-savings log.
Auto Trait Implementations§
impl !RefUnwindSafe for Greplm
impl !UnwindSafe for Greplm
impl Freeze for Greplm
impl Send for Greplm
impl Sync for Greplm
impl Unpin for Greplm
impl UnsafeUnpin for Greplm
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> 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