ratatui_toolkit/services/file_watcher/methods/unwatch.rs
1//! Stop watching a path.
2
3use notify::Watcher;
4use std::path::Path;
5
6use crate::services::file_watcher::FileWatcher;
7
8impl FileWatcher {
9 /// Stop watching a path.
10 ///
11 /// # Arguments
12 ///
13 /// * `path` - Path to stop watching.
14 ///
15 /// # Errors
16 ///
17 /// Returns a `notify::Error` if the path cannot be unwatched.
18 ///
19 /// # Example
20 ///
21 /// ```no_run
22 /// use ratatui_toolkit::services::file_watcher::FileWatcher;
23 /// use std::path::Path;
24 ///
25 /// let mut watcher = FileWatcher::new().unwrap();
26 /// let path = Path::new("README.md");
27 /// watcher.watch(path).unwrap();
28 /// // Later...
29 /// watcher.unwatch(path).unwrap();
30 /// ```
31 pub fn unwatch(&mut self, path: &Path) -> Result<(), notify::Error> {
32 self.watcher.unwatch(path)
33 }
34}