pub struct Watch {
pub dirty: Arc<AtomicBool>,
/* private fields */
}Expand description
Spawn a notify watcher rooted at the broker’s state/
directory. Returns None on platforms (or filesystems) where
notify can’t bring up a recommended watcher — the run loop
then falls back to the 1s poll. The returned Watch keeps the
underlying watcher alive; drop it to stop watching.
Fields§
§dirty: Arc<AtomicBool>Shared dirty flag — flipped to true on every relevant
filesystem event. The run loop reads + clears it via
take_dirty.
Implementations§
Source§impl Watch
impl Watch
Sourcepub fn idle() -> Self
pub fn idle() -> Self
Construct a watch with no underlying watcher. Used by tests
and as the fallback when notify::recommended_watcher
fails to initialise.
Sourcepub fn try_new(state_dir: &Path) -> Self
pub fn try_new(state_dir: &Path) -> Self
Try to build a recommended watcher rooted at state_dir.
Returns an idle (no-watcher) Watch on any failure so the
caller can still rely on the dirty-flag interface even when
the platform doesn’t support filesystem notifications.
Sourcepub fn take_dirty(&self) -> bool
pub fn take_dirty(&self) -> bool
Read + clear the dirty flag. Returns true exactly once per
batch of events the watcher saw since the previous call.
Auto Trait Implementations§
impl Freeze for Watch
impl !RefUnwindSafe for Watch
impl Send for Watch
impl !Sync for Watch
impl Unpin for Watch
impl UnsafeUnpin for Watch
impl !UnwindSafe for Watch
Blanket Implementations§
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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