Skip to main content

Module watcher

Module watcher 

Source
Expand description

Filesystem watcher for automatic file tracking and sync.

This module provides a filesystem watcher that:

  • Detects new files and auto-tracks them (unless ignored)
  • Detects modifications to tracked files and refreshes them
  • Batches changes and optionally syncs with peers

§Example

use darn_core::watcher::{Watcher, WatcherConfig, WatchEvent};

let config = WatcherConfig::default();
let (watcher, mut rx) = Watcher::new(&darn, config)?;

while let Some(event) = rx.recv().await {
    match event {
        WatchEvent::FileCreated(path) => println!("New: {}", path.display()),
        WatchEvent::FileModified(path) => println!("Modified: {}", path.display()),
        WatchEvent::FileDeleted(path) => println!("Deleted: {}", path.display()),
        WatchEvent::Error(e) => eprintln!("Error: {e}"),
    }
}

Structs§

WatchBatch
A batch of filesystem changes ready for processing.
WatchEventProcessor
Processes watch events and batches them for efficient handling.
WatchProcessResult
Result of processing a batch of watch events.
Watcher
Filesystem watcher for a darn workspace.
WatcherConfig
Configuration for the filesystem watcher.

Enums§

WatchEvent
Events emitted by the watcher.
WatcherError
Errors from the watcher.