pub struct Watcher { /* private fields */ }Expand description
A live watcher over one tree.
The watcher is movable to one consuming thread. It is intentionally not shareable:
its private standard-library receiver enforces one ordered consumer for coalesced
intents. Use a separate IndexHandle to serve concurrent readers and writers.
Dropping the watcher stops the OS watch and shuts the worker thread down.
Implementations§
Source§impl Watcher
impl Watcher
Sourcepub fn new(root: &Path, config: WatchConfig) -> Result<Self>
pub fn new(root: &Path, config: WatchConfig) -> Result<Self>
Start watching root recursively.
Sourcepub fn next_observation(&self, timeout: Duration) -> Result<Option<Observation>>
pub fn next_observation(&self, timeout: Duration) -> Result<Option<Observation>>
Block for and verify the next coalesced intent, up to timeout.
Filesystem calls happen synchronously on this consuming thread and may have
ordinary filesystem latency. A timeout, a stopped worker, and a panicked worker
are distinct outcomes. The returned observation contains relative paths but no
root identity; use Self::apply_next for the supported root-checked applying
driver rather than applying it to an arbitrary index.
Sourcepub fn apply_next(
&self,
index: &IndexHandle,
scan_config: &ScanConfig,
timeout: Duration,
sink: &mut dyn FnMut(&Commit),
) -> Result<Option<WatchApplyReport>>
pub fn apply_next( &self, index: &IndexHandle, scan_config: &ScanConfig, timeout: Duration, sink: &mut dyn FnMut(&Commit), ) -> Result<Option<WatchApplyReport>>
Apply one verified watch observation and close any invalidation loop it opens.
Restricted max_depth and one_filesystem scopes are rejected until the watch
adapter can filter raw backend events against those boundaries.