[][src]Struct notify::event::Event

pub struct Event {
    pub kind: EventKind,
    pub paths: Vec<PathBuf>,
    pub attrs: AnyMap,
}

Notify event.

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: AnyMap

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.

For vendor or custom information, it is recommended to use type wrappers to differentiate entries within the AnyMap container and avoid conflicts. For interoperability, one of the “well-known” types (or propose a new one) should be used instead. See the list on the wiki: https://github.com/passcod/notify/wiki/Well-Known-Event-Attrs

There is currently no way to serialise or deserialise arbitrary attributes, only well-known ones handled explicitly here are supported. This might change in the future.

Methods

impl Event[src]

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

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

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

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

pub fn info(&self) -> Option<&String>[src]

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

pub fn source(&self) -> Option<&String>[src]

Retrieves the source for an event directly, if present.

pub fn new(kind: EventKind) -> Self[src]

Creates a new Event given a kind.

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

Adds a path to the event.

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

Sets additional info onto the event.

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

Sets the Notify flag onto the event.

Trait Implementations

impl PartialEq<Event> for Event[src]

#[must_use] fn ne(&self, other: &Rhs) -> bool1.0.0[src]

This method tests for !=.

impl Eq for Event[src]

impl Default for Event[src]

impl Clone for Event[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Hash for Event[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for Event[src]

Auto Trait Implementations

impl Send for Event

impl Unpin for Event

impl Sync for Event

impl !UnwindSafe for Event

impl !RefUnwindSafe for Event

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> CloneAny for T where
    T: Clone + Any
[src]

impl<T> Erased for T