notify_types::event

Struct Event

Source
pub struct Event {
    pub kind: EventKind,
    pub paths: Vec<PathBuf>,
    pub attrs: EventAttributes,
}
Expand description

Notify event.

You might want to check Event::need_rescan to make sure no event was missed before you received this one.

Fields§

§kind: EventKind

Kind or type of the event.

This is a hierarchy of enums describing the event as precisely as possible. All enums in the hierarchy have two variants always present, Any and Other, accompanied by one or more specific variants.

Any should be used when more detail about the event is not known beyond the variant already selected. For example, AccessMode::Any means a file has been accessed, but that’s all we know.

Other should be used when more detail is available, but cannot be encoded as one of the defined variants. When specifying Other, the event attributes should contain an Info entry with a short string identifying this detail. That string is to be considered part of the interface of the backend (i.e. a change should probably be breaking).

For example, CreateKind::Other with an Info("mount") may indicate the binding of a mount. The documentation of the particular backend should indicate if any Other events are generated, and what their description means.

The EventKind::Any variant should be used as the “else” case when mapping native kernel bitmasks or bitmaps, such that if the mask is ever extended with new event types the backend will not gain bugs due to not matching new unknown event types.

§paths: Vec<PathBuf>

Paths the event is about, if known.

If an event concerns two or more paths, and the paths are known at the time of event creation, they should all go in this Vec. Otherwise, using the Tracker attr may be more appropriate.

The order of the paths is likely to be significant! For example, renames where both ends of the name change are known will have the “source” path first, and the “target” path last.

§attrs: EventAttributes

Additional attributes of the event.

Arbitrary data may be added to this field, without restriction beyond the Sync and Clone properties. Some data added here is considered for comparing and hashing, but not all: at this writing this is Tracker, Flag, Info, and Source.

Implementations§

Source§

impl Event

Source

pub fn need_rescan(&self) -> bool

Returns whether some events may have been missed. If true, you should assume any file or folder might have been modified.

See Flag::Rescan for more information.

Source

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

Retrieves the tracker ID for an event directly, if present.

Source

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

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

Source

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

Retrieves the additional info for an event directly, if present.

Source

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

Retrieves the source for an event directly, if present.

Source

pub fn new(kind: EventKind) -> Self

Creates a new Event given a kind.

Source

pub fn set_kind(self, kind: EventKind) -> Self

Sets the kind.

Source

pub fn add_path(self, path: PathBuf) -> Self

Adds a path to the event.

Source

pub fn add_some_path(self, path: Option<PathBuf>) -> Self

Adds a path to the event if the argument is Some.

Source

pub fn set_tracker(self, tracker: usize) -> Self

Sets the tracker.

Source

pub fn set_info(self, info: &str) -> Self

Sets additional info onto the event.

Source

pub fn set_flag(self, flag: Flag) -> Self

Sets the Notify flag onto the event.

Source

pub fn set_process_id(self, process_id: u32) -> Self

Sets the process id onto the event.

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

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

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

impl Default for Event

Source§

fn default() -> Self

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

impl Hash for Event

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 Event

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.