pub struct FileWatcherBuilder<R: Runtime> {
runtime: PhantomData<R>,
watching_dirs: HashMap<PathBuf, HashSet<DirEventFilter>>,
}
Expand description
Builder used to configure a FileWatcher
before it starts watching for changes.
Fields§
§runtime: PhantomData<R>
The runtime. We used to use this.
TODO get rid of this, but after we decide whether to keep using postage::watch. See the Warning note on Event.
watching_dirs: HashMap<PathBuf, HashSet<DirEventFilter>>
The list of directories that we’re currently watching.
Each directory has a set of filters that indicates whether a given notify::Event is relevant or not.
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.
Sourcefn watch_just_parents(&mut self, path: &Path) -> Result<PathBuf>
fn watch_just_parents(&mut self, path: &Path) -> Result<PathBuf>
Add the parents of path
to the list of things to watch.
Returns the absolute path of path
.
Idempotent.
Sourcefn watch_just_abs_dir(&mut self, watch_target: &Path, filter: DirEventFilter)
fn watch_just_abs_dir(&mut self, watch_target: &Path, filter: DirEventFilter)
Add just this (absolute) directory to the list of things to watch.
Does not watch any of the parents.
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