Skip to main content

Config

Struct Config 

Source
pub struct Config { /* private fields */ }
Expand description

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.

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§

Source§

impl Config

Source

pub fn with_poll_interval(self, dur: Duration) -> Self

For the PollWatcher backend.

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().

Source

pub fn poll_interval(&self) -> Option<Duration>

Returns current setting

Source

pub fn with_manual_polling(self) -> Self

For the PollWatcher backend.

Disable automatic polling. Requires calling crate::PollWatcher::poll() manually.

This will disable automatic polling, overwriting with_poll_interval().

Source

pub fn with_compare_contents(self, compare_contents: bool) -> Self

For the PollWatcher backend.

Optional feature that will evaluate the contents of changed files to determine if they have indeed changed using a fast hashing algorithm. This is especially important for pseudo filesystems like those on Linux under /sys and /proc which are not obligated to respect any other filesystem norms such as modification timestamps, file sizes, etc. By enabling this feature, performance will be significantly impacted as all files will need to be read and hashed at each poll_interval.

This can’t be changed during runtime. Off by default.

Source

pub fn compare_contents(&self) -> bool

Returns current setting

For the INotifyWatcher, KqueueWatcher, and PollWatcher.

Determine if symbolic links should be followed when recursively watching a directory.

This can’t be changed during runtime. On by default.

Returns current setting

Source

pub fn with_event_kinds(self, event_kinds: EventKindMask) -> Self

Filter 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 EventKindMask::ALL, which includes all events. Use EventKindMask::CORE to exclude 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);
Source

pub fn event_kinds(&self) -> EventKindMask

Returns current setting

Source

pub fn with_windows_path_separator_style( self, style: WindowsPathSeparatorStyle, ) -> Self

For the ReadDirectoryChangesWatcher backend.

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.

Source

pub fn windows_path_separator_style(&self) -> WindowsPathSeparatorStyle

Returns current setting.

Source

pub fn with_fsevent_latency(self, latency: Duration) -> Self

For the FsEventWatcher backend.

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.

Source

pub fn fsevent_latency(&self) -> Duration

Returns current setting

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Config

Source§

impl Debug for Config

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Config

Source§

impl Hash for Config

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Config

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.