Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add accessor for whether rescan is required on Event #435

Merged
merged 1 commit into from Aug 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions notify/src/event.rs
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