Skip to main content

EventAttributes

Struct EventAttributes 

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

Additional attributes of the event.

Attributes are optional and their availability depends on the backend and event. See tracker, info, and source for details.

Implementations§

Source§

impl EventAttributes

Source

pub fn new() -> Self

Creates a new EventAttributes.

Source

pub fn tracker(&self) -> Option<usize>

Returns a tracking ID (also called a cookie) for related events, if present.

A backend may assign the same ID to multiple events that describe a single operation. For example, the inotify backend uses a rename cookie to associate RenameMode::From and RenameMode::To events for the same rename. If it also emits a RenameMode::Both event, that event has the same ID.

Use this value to match related events from the same watcher. Treat it as an opaque value: its meaning and lifetime depend on the backend, and it is not a persistent file identifier or a globally unique event ID.

Returns None when the backend or event does not provide a tracking ID.

Source

pub fn flag(&self) -> Option<Flag>

Retrieves the Notify flag for an event directly, if present.

Source

pub fn info(&self) -> Option<&str>

Returns additional, backend-provided information about this event, if present.

This attribute is primarily used to disambiguate the various Other variants in the EventKind hierarchy (for example EventKind::Other, CreateKind::Other, ModifyKind::Other, RemoveKind::Other, MetadataKind::Other, …).

When a backend emits an Other kind, it should also set this attribute to a short, human-readable string explaining what happened. If an event kind indicates Other but this value is missing, treat it as a backend bug.

Backends may also set this attribute for non-Other kinds, if doing so provides useful precision. For example, the Modify(Metadata(Extended)) kind suggests using this attribute when information about what extended metadata changed is available.

§Stability

The exact string values are backend-defined. They are intended as a hint for consumers and may change between notify versions.

§Examples

notify backends and debouncers currently use values such as:

  • unmount (inotify unmount events)
  • rescan: user dropped / rescan: kernel dropped (FSEvents queue overflow hints)
  • root changed (FSEvents watched root renamed or removed)
  • mount (FSEvents mount or unmount events)
  • is: symlink, is: hardlink, is: clone (FSEvents item type hints)
  • meta: finder info (FSEvents Finder metadata changes)
  • override (a synthetic removal from notify-debouncer-full when a rename replaces an existing target)
Source

pub fn source(&self) -> Option<&str>

Returns a string identifying the backend that produced the event, if present.

This is intended to be a short, unambiguous backend name. A dynamically generated value should include a prefix that identifies the backend.

The built-in notify backends currently leave this attribute unset, so their events return None. A value can be present in events deserialized with the serde feature.

Source

pub fn process_id(&self) -> Option<u32>

The process ID of the originator of the event.

This attribute is experimental and, while included in Notify itself, is not considered stable or standard enough to be part of the serde, eq, hash, and debug representations.

Source

pub fn set_tracker(&mut self, tracker: usize)

Source

pub fn set_flag(&mut self, flag: Flag)

Sets the Notify flag onto the event.

Source

pub fn set_info(&mut self, info: &str)

Sets EventAttributes::info.

This should be a short, human-readable string.

Source

pub fn set_process_id(&mut self, process_id: u32)

Sets the process id onto the event.

Trait Implementations§

Source§

impl Clone for EventAttributes

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 Debug for EventAttributes

Source§

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

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

impl Default for EventAttributes

Source§

fn default() -> Self

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

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.