pub struct FileWatcherBuilder<R: Runtime> { /* private fields */ }
Expand description
Builder used to configure a FileWatcher
before it starts watching for changes.
Implementations§
Source§impl<R: Runtime> FileWatcherBuilder<R>
impl<R: Runtime> FileWatcherBuilder<R>
Sourcepub fn watch_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
pub fn watch_path<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Add a single path to the list of things to watch.
The event receiver will be notified if the path is created, modified, renamed, or removed.
If the path is a directory, its contents will not be watched.
To watch the contents of a directory, use watch_dir
.
Idempotent: does nothing if we’re already watching that path.
Sourcepub fn watch_dir<P: AsRef<Path>, S: AsRef<str>>(
&mut self,
path: P,
extension: S,
) -> Result<()>
pub fn watch_dir<P: AsRef<Path>, S: AsRef<str>>( &mut self, path: P, extension: S, ) -> Result<()>
Add a directory (but not any subdirs) to the list of things to watch.
The event receiver will be notified whenever a file with the specified extension
is created within this directory, or if an existing file with this extension
is modified, renamed, or removed.
Changes to files that have a different extension are ignored.
Idempotent.
Sourcepub fn start_watching(self, tx: FileEventSender) -> Result<FileWatcher>
pub fn start_watching(self, tx: FileEventSender) -> Result<FileWatcher>
Build a FileWatcher
and start sending events to tx
.
On startup, the watcher sends a Rescan
event.
This helps mitigate the event loss that occurs if the watched files are modified between
the time they are initially loaded and the time when the watcher is set up.
Auto Trait Implementations§
impl<R> Freeze for FileWatcherBuilder<R>
impl<R> RefUnwindSafe for FileWatcherBuilder<R>where
R: RefUnwindSafe,
impl<R> Send for FileWatcherBuilder<R>
impl<R> Sync for FileWatcherBuilder<R>
impl<R> Unpin for FileWatcherBuilder<R>where
R: Unpin,
impl<R> UnwindSafe for FileWatcherBuilder<R>where
R: UnwindSafe,
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
§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