pub struct Watch { /* private fields */ }Expand description
A running watch. Owns the receiving end of the batch channel.
Dropping it stops the watch, and for a backend with a worker thread, ends and joins that thread before drop
returns. Nothing keeps running after it.
Implementations§
Source§impl Watch
impl Watch
Sourcepub fn new(
rx: Receiver<WatchBatch>,
on_drop: impl FnOnce() + Send + 'static,
) -> Self
pub fn new( rx: Receiver<WatchBatch>, on_drop: impl FnOnce() + Send + 'static, ) -> Self
Build a watch from a receiver and the action that stops its producer. For backend authors: on_drop runs once
when the Watch is dropped and must stop (and, for a thread, join) whatever feeds rx.
Sourcepub fn map_paths(
self,
f: impl Fn(&NsPath) -> Option<NsPath> + Send + Sync + 'static,
) -> Self
pub fn map_paths( self, f: impl Fn(&NsPath) -> Option<NsPath> + Send + Sync + 'static, ) -> Self
Rewrite every path in every batch with f as it is received. f returns None for a path that cannot be
represented; the batch is then marked rescan (a path was lost, so the consumer must look). The
Namespace uses this to turn mount-relative paths into namespace paths.
Sourcepub fn recv(&self) -> Result<WatchBatch, RecvError>
pub fn recv(&self) -> Result<WatchBatch, RecvError>
Block until the next batch. Err means the watch’s producer is gone.
Sourcepub fn recv_timeout(
&self,
timeout: Duration,
) -> Result<WatchBatch, RecvTimeoutError>
pub fn recv_timeout( &self, timeout: Duration, ) -> Result<WatchBatch, RecvTimeoutError>
Block for at most timeout.
Sourcepub fn try_recv(&self) -> Result<WatchBatch, TryRecvError>
pub fn try_recv(&self) -> Result<WatchBatch, TryRecvError>
Return a batch if one is ready.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Watch
impl !Sync for Watch
impl !UnwindSafe for Watch
impl Forget for Watch
impl Freeze for Watch
impl Move for Watch
impl Send for Watch
impl Unpin for Watch
impl UnsafeUnpin 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