Struct EventKindMask

pub struct EventKindMask(/* private field */);

A bitmask specifying which event kinds to monitor.

This type allows fine-grained control over which filesystem events are reported. 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.

Examples

use notify_types::event::EventKindMask;

// Monitor only file creations and deletions
let mask = EventKindMask::CREATE | EventKindMask::REMOVE;

// Monitor everything including access events
let all = EventKindMask::ALL;

// Default: includes all events (matches Config::default())
let default = EventKindMask::default();
assert_eq!(default, EventKindMask::ALL);

Implementations

impl EventKindMask

const fn empty() -> Self

Get a flags value with all bits unset.

const fn all() -> Self

Get a flags value with all known bits set.

const fn bits(&self) -> u32

Get the underlying bits value.

The returned value is exactly the bits set in this flags value.

const fn from_bits(bits: u32) -> Option<Self>

Convert from a bits value.

This method will return None if any unknown bits are set.

const fn from_bits_truncate(bits: u32) -> Self

Convert from a bits value, unsetting any unknown bits.

const fn from_bits_retain(bits: u32) -> Self

Convert from a bits value exactly.

fn from_name(name: &str) -> Option<Self>

Get a flags value with the bits of a flag with the given name set.

This method will return None if name is empty or doesn't correspond to any named flag.

const fn is_empty(&self) -> bool

Whether all bits in self are unset.

const fn is_all(&self) -> bool

Whether all known bits in this flags value are set.

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

Whether any set bits in other are also set in self.

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

Whether all set bits in other are also set in self.

fn insert(&mut self, other: Self)

The bitwise or (|) of the bits in self and other.

fn remove(&mut self, other: Self)

The intersection of self with the complement of other (&!).

This method is not equivalent to self & !other when other has unknown bits set. remove won't truncate other, but the ! operator will.

fn toggle(&mut self, other: Self)

The bitwise exclusive-or (^) of the bits in self and other.

fn set(&mut self, other: Self, value: bool)

Call insert when value is true or remove when value is false.

const fn intersection(self, other: Self) -> Self

The bitwise and (&) of the bits in self and other.

const fn union(self, other: Self) -> Self

The bitwise or (|) of the bits in self and other.

const fn difference(self, other: Self) -> Self

The intersection of self with the complement of other (&!).

This method is not equivalent to self & !other when other has unknown bits set. difference won't truncate other, but the ! operator will.

const fn symmetric_difference(self, other: Self) -> Self

The bitwise exclusive-or (^) of the bits in self and other.

const fn complement(self) -> Self

The bitwise negation (!) of the bits in self, truncating the result.

impl EventKindMask

fn matches(&self, kind: &EventKind) -> bool

Returns whether the given event kind matches this mask.

EventKind::Any and EventKind::Other always pass regardless of the mask, as they represent meta-events that should not be filtered.

Examples

use notify_types::event::{EventKindMask, EventKind, CreateKind, AccessKind, AccessMode};

let mask = EventKindMask::CREATE;
assert!(mask.matches(&EventKind::Create(CreateKind::File)));
assert!(!mask.matches(&EventKind::Access(AccessKind::Open(AccessMode::Read))));

// Any and Other always pass
let empty = EventKindMask::empty();
assert!(empty.matches(&EventKind::Any));
assert!(empty.matches(&EventKind::Other));

impl EventKindMask

const fn iter(&self) -> Iter<EventKindMask>

Yield a set of contained flags values.

Each yielded flags value will correspond to a defined named flag. Any unknown bits will be yielded together as a final flags value.

const fn iter_names(&self) -> IterNames<EventKindMask>

Yield a set of contained named flags values.

This method is like iter, except only yields bits in contained named flags. Any unknown bits, or bits not corresponding to a contained flag will not be yielded.

impl EventKindMask

const CREATE: Self = _;

Monitor file/folder creation events.

const REMOVE: Self = _;

Monitor file/folder removal events.

const MODIFY_DATA: Self = _;

Monitor data modification events (content/size changes).

const MODIFY_META: Self = _;

Monitor metadata modification events (permissions, timestamps, etc).

const MODIFY_NAME: Self = _;

Monitor name/rename events.

const ACCESS_OPEN: Self = _;

Monitor file open events.

const ACCESS_CLOSE: Self = _;

Monitor file close events after writing. This fires when a file opened for writing is closed.

const ACCESS_CLOSE_NOWRITE: Self = _;

Monitor file close events after read-only access. This fires when a file opened for reading (not writing) is closed. Note: This can be very noisy and may cause queue overflow on busy systems.

const ALL_MODIFY: Self = _;

All modify events (data, metadata, and name changes).

const ALL_ACCESS: Self = _;

All access events (open, close-write, and close-nowrite).

const CORE: Self = _;

Core events: create, remove, and all modify events. This is the default and matches the current notify behavior (no access events).

const ALL: Self = _;

All events including access events.

Trait Implementations

impl Binary for EventKindMask

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

impl BitAnd for EventKindMask

type Output = EventKindMask;
fn bitand(self, other: Self) -> Self

The bitwise and (&) of the bits in self and other.

impl BitAndAssign for EventKindMask

fn bitand_assign(&mut self, other: Self)

The bitwise and (&) of the bits in self and other.

impl BitOr for EventKindMask

type Output = EventKindMask;
fn bitor(self, other: EventKindMask) -> Self

The bitwise or (|) of the bits in self and other.

impl BitOrAssign for EventKindMask

fn bitor_assign(&mut self, other: Self)

The bitwise or (|) of the bits in self and other.

impl BitXor for EventKindMask

type Output = EventKindMask;
fn bitxor(self, other: Self) -> Self

The bitwise exclusive-or (^) of the bits in self and other.

impl BitXorAssign for EventKindMask

fn bitxor_assign(&mut self, other: Self)

The bitwise exclusive-or (^) of the bits in self and other.

impl Clone for EventKindMask

fn clone(&self) -> EventKindMask

impl Copy for EventKindMask

impl Debug for EventKindMask

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

impl Default for EventKindMask

fn default() -> Self

impl Eq for EventKindMask

impl Extend<EventKindMask> for EventKindMask

fn extend<T: IntoIterator<Item = Self>>(&mut self, iterator: T)

The bitwise or (|) of the bits in each flags value.

impl Flags for EventKindMask

const FLAGS: &'static [Flag<EventKindMask>] = _;
type Bits = u32;
fn bits(&self) -> u32
fn from_bits_retain(bits: u32) -> EventKindMask
fn all_named() -> EventKindMask

impl FromIterator<EventKindMask> for EventKindMask

fn from_iter<T: IntoIterator<Item = Self>>(iterator: T) -> Self

The bitwise or (|) of the bits in each flags value.

impl Hash for EventKindMask

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

impl IntoIterator for EventKindMask

type Item = EventKindMask;
type IntoIter = Iter<EventKindMask>;
fn into_iter(self) -> Self::IntoIter

impl LowerHex for EventKindMask

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

impl Not for EventKindMask

type Output = EventKindMask;
fn not(self) -> Self

The bitwise negation (!) of the bits in self, truncating the result.

impl Octal for EventKindMask

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

impl PartialEq for EventKindMask

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

impl PublicFlags for EventKindMask

type Primitive = u32;
type Internal = InternalBitFlags;

impl StructuralPartialEq for EventKindMask

impl Sub for EventKindMask

type Output = EventKindMask;
fn sub(self, other: Self) -> Self

The intersection of self with the complement of other (&!).

This method is not equivalent to self & !other when other has unknown bits set. difference won't truncate other, but the ! operator will.

impl SubAssign for EventKindMask

fn sub_assign(&mut self, other: Self)

The intersection of self with the complement of other (&!).

This method is not equivalent to self & !other when other has unknown bits set. difference won't truncate other, but the ! operator will.

impl UpperHex for EventKindMask

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

Auto Trait Implementations

impl Freeze for EventKindMask

impl RefUnwindSafe for EventKindMask

impl Send for EventKindMask

impl Sync for EventKindMask

impl Unpin for EventKindMask

impl UnsafeUnpin for EventKindMask

impl UnwindSafe for EventKindMask

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

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

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

impl<T> From<T> for EventKindMask

fn from(t: T) -> T

Returns the argument unchanged.

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

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

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

fn into(self) -> U

Calls U::from(self).

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

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

type Error = never;
fn try_from(value: U) -> Result<T, never>

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

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