ratatui_toolkit/services/file_watcher/constructors/
new.rs

1//! Default constructor for FileWatcher.
2
3use notify::{Config, RecommendedWatcher, Watcher};
4use std::sync::mpsc::channel;
5use std::time::Duration;
6
7use crate::services::file_watcher::{FileWatcher, WatchConfig};
8
9impl FileWatcher {
10    /// Create a new file watcher with default configuration.
11    ///
12    /// Uses `WatchMode::File` (non-recursive) and 100ms debounce by default.
13    ///
14    /// # Errors
15    ///
16    /// Returns a `notify::Error` if the watcher cannot be created.
17    ///
18    /// # Example
19    ///
20    /// ```no_run
21    /// use ratatui_toolkit::services::file_watcher::FileWatcher;
22    ///
23    /// let watcher = FileWatcher::new().unwrap();
24    /// ```
25    pub fn new() -> Result<Self, notify::Error> {
26        Self::with_config(WatchConfig::default())
27    }
28}