pub struct FileSystemWatcher { /* private fields */ }Expand description
Filesystem watcher that emits debounced batches of dirty paths.
Uses notify-debouncer-mini for event coalescing. All paths within the debounce window are collected, de-duplicated, sorted, and emitted as a single WatcherBatch.
Implementations§
Source§impl FileSystemWatcher
impl FileSystemWatcher
Sourcepub fn new(
path: PathBuf,
config: WatcherConfig,
shutdown: Arc<AtomicBool>,
) -> Result<Self>
pub fn new( path: PathBuf, config: WatcherConfig, shutdown: Arc<AtomicBool>, ) -> Result<Self>
Sourcepub fn recv_batch(&self) -> Option<WatcherBatch>
pub fn recv_batch(&self) -> Option<WatcherBatch>
Receive the next batch, blocking until available.
§Returns
None if the watcher thread has terminated
Sourcepub fn try_recv_batch(&self) -> Option<WatcherBatch>
pub fn try_recv_batch(&self) -> Option<WatcherBatch>
Try to receive a batch without blocking.
§Returns
Some(batch)if a batch is availableNoneif no batch is available or watcher terminated
Sourcepub fn recv_batch_timeout(
&self,
timeout: Duration,
) -> Result<Option<WatcherBatch>, ()>
pub fn recv_batch_timeout( &self, timeout: Duration, ) -> Result<Option<WatcherBatch>, ()>
Receive the next batch with a timeout.
§Returns
Ok(Some(batch))if a batch is availableOk(None)if the watcher thread has terminatedErrif timeout elapsed
Sourcepub fn try_recv_event(&self) -> Result<Option<FileEvent>>
pub fn try_recv_event(&self) -> Result<Option<FileEvent>>
Legacy: Try to receive a single event without blocking (DEPRECATED).
This method converts batch events to single events for backward compatibility. Paths from each batch are returned one at a time in sorted order.
§Deprecated
Use try_recv_batch() instead for deterministic batch processing.
§Errors
Returns an error if a mutex is poisoned (thread panicked while holding the lock).
Sourcepub fn recv_event(&self) -> Result<Option<FileEvent>>
pub fn recv_event(&self) -> Result<Option<FileEvent>>
Legacy: Receive the next event, blocking until available (DEPRECATED).
This method converts batch events to single events for backward compatibility. Paths from each batch are returned one at a time in sorted order.
§Deprecated
Use recv_batch() instead for deterministic batch processing.
§Errors
Returns an error if a mutex is poisoned (thread panicked while holding the lock).
Sourcepub fn shutdown(self)
pub fn shutdown(self)
Explicitly shut down the watcher and join all background threads.
This method consumes the watcher, ensuring that:
- The pub/sub receiver is shut down cleanly (if present)
- The watcher thread is joined (waits for clean termination)
§Note
This method should be called during graceful shutdown to ensure all threads have terminated before the program exits.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileSystemWatcher
impl !RefUnwindSafe for FileSystemWatcher
impl Send for FileSystemWatcher
impl !Sync for FileSystemWatcher
impl Unpin for FileSystemWatcher
impl UnsafeUnpin for FileSystemWatcher
impl !UnwindSafe for FileSystemWatcher
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> 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