Struct Config
pub struct Config { /* private fields */ }
Watcher Backend configuration
This contains multiple settings that may relate to only one specific backend, such as to correctly configure each backend regardless of what is selected during runtime.
# use std::time::Duration;
# use notify::Config;
let config = Config::default()
.with_poll_interval(Duration::from_secs(2))
.with_compare_contents(true);
Some options can be changed during runtime, others have to be set when creating the watcher backend.
Implementations
impl Config
fn with_poll_interval(self, dur: Duration) -> SelfFor the
PollWatcherbackend.Interval between each re-scan attempt. This can be extremely expensive for large file trees so it is recommended to measure and tune accordingly.
The default poll frequency is 30 seconds.
This will enable automatic polling, overwriting
with_manual_polling().fn poll_interval(&self) -> Option<Duration>Returns current setting
fn with_manual_polling(self) -> SelfFor the
PollWatcherbackend.Disable automatic polling. Requires calling [
crate::PollWatcher::poll()] manually.This will disable automatic polling, overwriting
with_poll_interval().fn with_compare_contents(self, compare_contents: bool) -> SelfCompare file contents for
PollWatcher.When enabled, each scan reads and hashes every regular file, increasing I/O and CPU usage. Content changes produce
Modify(Data(Any)); modification time changes with identical contents produceModify(Metadata(WriteTime)).Without it, changes to a regular file's size or modification time produce
Modify(Data(Any)), includingtouch. Changes preserving both go undetected, as can happen on/procand/sys.Disabled by default; cannot be changed at runtime.
fn compare_contents(&self) -> boolReturns current setting
fn with_follow_symlinks(self, follow_symlinks: bool) -> SelfFor the
INotifyWatcher,KqueueWatcher, andPollWatcher.Determine if symbolic links should be followed when recursively watching a directory.
This can't be changed during runtime. On by default.
fn follow_symlinks(&self) -> boolReturns current setting
fn with_event_kinds(self, event_kinds: EventKindMask) -> SelfFilter which event kinds are monitored.
This allows you to control which types of filesystem events are delivered to your event handler. On backends that support kernel-level filtering (inotify), the mask is translated to native flags for optimal performance. On other backends (kqueue, Windows, FSEvents, PollWatcher), filtering is applied in userspace.
The default is
CORE | ACCESS_OPEN | ACCESS_CLOSE, the events that notify v8 reported.EventKindMask::ALL(alsoEventKindMask::default()) addsACCESS_CLOSE_NOWRITE, which reports closing a file or directory that was opened without write access. Recursive registration itself generates access events as it reads directories. UseEventKindMask::COREto exclude access events, orCORE | ACCESS_CLOSEto keep close-after-write notifications without these directory access events.This can't be changed during runtime.
Example
use notify::{Config, EventKindMask}; // Only monitor file creation and deletion let config = Config::default() .with_event_kinds(EventKindMask::CREATE | EventKindMask::REMOVE); // Monitor everything including access events let config_all = Config::default() .with_event_kinds(EventKindMask::ALL);fn event_kinds(&self) -> EventKindMaskReturns current setting
fn with_windows_path_separator_style(self, style: WindowsPathSeparatorStyle) -> SelfFor the
ReadDirectoryChangesWatcherbackend.Controls path separator normalization for emitted event paths on Windows.
The default is
WindowsPathSeparatorStyle::Auto, which preserves the separator style implied by each watched input path.This can't be changed during runtime.
fn windows_path_separator_style(&self) -> WindowsPathSeparatorStyleReturns current setting.
fn with_windows_extended_information(self, extended_information: bool) -> SelfUse
ReadDirectoryChangesExWto classify created and removed entries as files or folders. Reparse points are not followed; modification events remainModifyKind::Any.Requires Windows 10 1709 / Windows Server 2019 or later and NTFS. Unsupported APIs fail at construction; unsupported filesystems fail at
watch()or via the event handler. No automatic fallback: use a default-configured watcher for unsupported paths.Off by default and ignored by other backends. Cannot be changed via
Watcher::configure; create a new watcher to switch modes. Both notification modes use a 64 KiB read buffer per OS watch.fn windows_extended_information(&self) -> boolReturns whether extended directory notifications are enabled on Windows.
fn with_fsevent_latency(self, latency: Duration) -> SelfFor the
FsEventWatcherbackend.The latency passed to
FSEventStreamCreate: how long the FSEvents service waits after hearing about an event from the kernel before invoking the callback. A larger value lets the system coalesce bursts of changes into fewer callbacks at the cost of higher delivery latency.This watcher is created with
kFSEventStreamCreateFlagNoDefer, so the first event in an idle period is delivered immediately; only subsequent events get coalesced within the latency window.The default is
Duration::ZERO.This can't be changed during runtime.
fn fsevent_latency(&self) -> DurationReturns current setting
Trait Implementations
impl Clone for Config
fn clone(&self) -> Self
impl Debug for Config
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for Config
fn default() -> Self
impl Eq for Config
impl Hash for Config
fn hash<__H: Hasher>(&self, state: &mut __H)
impl PartialEq for Config
fn eq(&self, other: &Self) -> bool