diff --git a/notify-debouncer-mini/src/lib.rs b/notify-debouncer-mini/src/lib.rs index ec027a8..a93af50 100644 --- a/notify-debouncer-mini/src/lib.rs +++ b/notify-debouncer-mini/src/lib.rs @@ -24,7 +24,7 @@ //! # fn main() { //! // setup initial watcher backend config //! let config = Config::default(); -//! +//! //! // Select recommended watcher for debouncer. //! // Using a callback here, could also be a channel. //! let mut debouncer = new_debouncer(Duration::from_secs(2), None, |res: DebounceEventResult| { @@ -266,7 +266,7 @@ pub fn new_debouncer_opt( timeout: Duration, tick_rate: Option, mut event_handler: F, - config: notify::Config + config: notify::Config, ) -> Result, Error> { let data = DebounceData::default(); @@ -320,15 +320,18 @@ pub fn new_debouncer_opt( } })?; - let watcher = T::new(move |e: Result| { - let mut lock = data.lock().expect("Can't lock debouncer data!"); + let watcher = T::new( + move |e: Result| { + let mut lock = data.lock().expect("Can't lock debouncer data!"); - match e { - Ok(e) => lock.add_event(e), - // can't have multiple TX, so we need to pipe that through our debouncer - Err(e) => lock.add_error(e), - } - }, config)?; + match e { + Ok(e) => lock.add_event(e), + // can't have multiple TX, so we need to pipe that through our debouncer + Err(e) => lock.add_error(e), + } + }, + config, + )?; let guard = Debouncer { watcher, @@ -347,7 +350,12 @@ pub fn new_debouncer_opt( pub fn new_debouncer( timeout: Duration, tick_rate: Option, - event_handler: F + event_handler: F, ) -> Result, Error> { - new_debouncer_opt::(timeout, tick_rate, event_handler, notify::Config::default()) + new_debouncer_opt::( + timeout, + tick_rate, + event_handler, + notify::Config::default(), + ) } diff --git a/notify-debouncer-refined/src/cache.rs b/notify-debouncer-refined/src/cache.rs index f190da7..2260f22 100644 --- a/notify-debouncer-refined/src/cache.rs +++ b/notify-debouncer-refined/src/cache.rs @@ -8,26 +8,26 @@ use notify::RecursiveMode; use walkdir::WalkDir; /// The interface of a file ID cache. -/// +/// /// This trait can be implemented for an existing cache, if it already holds `FileId`s. pub trait FileIdCache { /// Get a `FileId` from the cache for a given `path`. - /// + /// /// If the path is not cached, `None` should be returned and there should not be any attempt to read the file ID from disk. fn cached_file_id(&self, path: &Path) -> Option<&FileId>; /// Add a new path to the cache or update its value. - /// + /// /// This will be called if a new file or directory is created or if an existing file is overridden. fn add_path(&mut self, path: &Path); /// Remove a path from the cache. - /// + /// /// This will be called if a file or directory is deleted. fn remove_path(&mut self, path: &Path); /// Re-scan all paths. - /// + /// /// This will be called if the notification back-end has dropped events. fn rescan(&mut self); } @@ -49,7 +49,7 @@ impl FileIdMap { } /// Add a path to the cache. - /// + /// /// If `recursive_mode` is `Recursive`, all children will be added to the cache as well /// and all paths will be kept up-to-date in case of changes like new files being added, /// files being removed or renamed. @@ -62,7 +62,7 @@ impl FileIdMap { } /// Remove a path form the cache. - /// + /// /// If the path was added with `Recursive` mode, all children will also be removed from the cache. pub fn remove_root(&mut self, path: impl AsRef) { self.roots.retain(|(root, _)| !root.starts_with(&path));