Skip to content

Commit

Permalink
add accessor for whether rescan is required on Event
Browse files Browse the repository at this point in the history
  • Loading branch information
trinity-1686a authored and 0xpr03 committed Aug 17, 2022
1 parent 17580f6 commit 1fbf8fa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions notify/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ impl Default for EventKind {
}

/// Notify event.
///
/// You might want to check [`Event::need_rescan`] to make sure no event was missed before you
/// received this one.
#[derive(Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Event {
Expand Down Expand Up @@ -505,6 +508,13 @@ pub enum Flag {
}

impl Event {
/// 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.
pub fn need_rescan(&self) -> bool {
matches!(self.flag(), Some(Flag::Rescan))
}
/// Retrieves the tracker ID for an event directly, if present.
pub fn tracker(&self) -> Option<usize> {
self.attrs.tracker()
Expand Down

0 comments on commit 1fbf8fa

Please sign in to comment.