Struct Event
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§
§impl Event
impl Event
pub fn need_rescan(&self) -> bool
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.
pub fn add_some_path(self, path: Option<PathBuf>) -> Event
pub fn add_some_path(self, path: Option<PathBuf>) -> Event
Adds a path to the event if the argument is Some.
pub fn set_tracker(self, tracker: usize) -> Event
pub fn set_tracker(self, tracker: usize) -> Event
Sets the tracker.
pub fn set_process_id(self, process_id: u32) -> Event
pub fn set_process_id(self, process_id: u32) -> Event
Sets the process id onto the event.
Trait Implementations§
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> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> FsChangeNote for T
impl<T> FsChangeNote for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more