Skip to content

Commit

Permalink
code format by cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
coswat authored and 0xpr03 committed Sep 30, 2023
1 parent 777dfa0 commit 146790b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 28 deletions.
10 changes: 4 additions & 6 deletions examples/debouncer_mini_custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ fn main() {
// notify backend configuration
let backend_config = notify::Config::default().with_poll_interval(Duration::from_secs(1));
// debouncer configuration
let debouncer_config = Config::default().with_timeout(Duration::from_millis(1000)).with_notify_config(backend_config);
let debouncer_config = Config::default()
.with_timeout(Duration::from_millis(1000))
.with_notify_config(backend_config);
// select backend via fish operator, here PollWatcher backend
let mut debouncer = new_debouncer_opt::<_, notify::PollWatcher>(
debouncer_config,
tx,
)
.unwrap();
let mut debouncer = new_debouncer_opt::<_, notify::PollWatcher>(debouncer_config, tx).unwrap();

debouncer
.watcher()
Expand Down
17 changes: 8 additions & 9 deletions examples/pollwatcher_manual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ fn main() {
fn watch<P: AsRef<Path>>(path: P) -> notify::Result<()> {
let (tx, rx) = std::sync::mpsc::channel();
// use the PollWatcher and disable automatic polling
let mut watcher = PollWatcher::new(
tx,
Config::default().with_manual_polling(),
)?;
let mut watcher = PollWatcher::new(tx, Config::default().with_manual_polling())?;

// Add a path to be watched. All files and directories at that path and
// below will be monitored for changes.
watcher.watch(path.as_ref(), RecursiveMode::Recursive)?;

// run event receiver on a different thread, we want this one for user input
std::thread::spawn(move ||{for res in rx {
match res {
Ok(event) => println!("changed: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
std::thread::spawn(move || {
for res in rx {
match res {
Ok(event) => println!("changed: {:?}", event),
Err(e) => println!("watch error: {:?}", e),
}
}
}});
});

// wait for any input and poll
loop {
Expand Down
4 changes: 2 additions & 2 deletions notify-debouncer-full/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
//! - `crossbeam` enabled by default, adds [`DebounceEventHandler`](DebounceEventHandler) support for crossbeam channels.
//! Also enables crossbeam-channel in the re-exported notify. You may want to disable this when using the tokio async runtime.
//! - `serde` enables serde support for events.
//!
//!
//! # Caveats
//!
//!
//! As all file events are sourced from notify, the [known problems](https://docs.rs/notify/latest/notify/#known-problems) section applies here too.

mod cache;
Expand Down
6 changes: 3 additions & 3 deletions notify-debouncer-mini/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
//! // Add a path to be watched. All files and directories at that path and
//! // below will be monitored for changes.
//! debouncer.watcher().watch(Path::new("."), RecursiveMode::Recursive).unwrap();
//!
//!
//! // note that dropping the debouncer (as will happen here) also ends the debouncer
//! // thus this demo would need an endless loop to keep running
//! # }
Expand All @@ -48,9 +48,9 @@
//! - `crossbeam` enabled by default, adds [`DebounceEventHandler`](DebounceEventHandler) support for crossbeam channels.
//! Also enables crossbeam-channel in the re-exported notify. You may want to disable this when using the tokio async runtime.
//! - `serde` enables serde support for events.
//!
//!
//! # Caveats
//!
//!
//! As all file events are sourced from notify, the [known problems](https://docs.rs/notify/latest/notify/#known-problems) section applies here too.
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
Expand Down
6 changes: 3 additions & 3 deletions notify/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Config {
/// file trees so it is recommended to measure and tune accordingly.
///
/// The default poll frequency is 30 seconds.
///
///
/// This will enable automatic polling, overwriting [with_manual_polling](Config::with_manual_polling).
pub fn with_poll_interval(mut self, dur: Duration) -> Self {
// TODO: v7.0 break signature to option
Expand All @@ -76,9 +76,9 @@ impl Config {
}

/// For the [PollWatcher](crate::PollWatcher) backend.
///
///
/// Disable automatic polling. Requires calling [crate::PollWatcher::poll] manually.
///
///
/// This will disable automatic polling, overwriting [with_poll_interval](Config::with_poll_interval).
pub fn with_manual_polling(mut self) -> Self {
self.poll_interval = None;
Expand Down
10 changes: 5 additions & 5 deletions notify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@
//! Note the `macos_kqueue` requirement here, otherwise no native backend is available on macos.
//!
//! # Known Problems
//!
//!
//! ### Network filesystems
//!
//!
//! Network mounted filesystems like NFS may not emit any events for notify to listen to.
//! This applies especially to WSL programs watching windows paths ([issue #254](https://github.com/notify-rs/notify/issues/254)).
//!
//!
//! A workaround is the [PollWatcher] backend.
//!
//! ### Docker with Linux on MacOS M1
Expand Down Expand Up @@ -92,10 +92,10 @@
//! Note that the [PollWatcher] is not restricted by this limitation, so it may be an alternative if your users can't increase the limit.
//!
//! ### Watching large directories
//!
//!
//! When watching a very large amount of files, notify may fail to receive all events.
//! For example the linux backend is documented to not be a 100% reliable source. See also issue [#412](https://github.com/notify-rs/notify/issues/412).
//!
//!
//! # Examples
//!
//! For more examples visit the [examples folder](https://github.com/notify-rs/notify/tree/main/examples) in the repository.
Expand Down

0 comments on commit 146790b

Please sign in to comment.