Skip to content

Commit 40ec37f

Browse files
committed
cargo fmt over everything
1 parent 0611b06 commit 40ec37f

File tree

8 files changed

+63
-58
lines changed

8 files changed

+63
-58
lines changed

examples/async_monitor.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use futures::{
22
channel::mpsc::{channel, Receiver},
33
SinkExt, StreamExt,
44
};
5-
use notify::{Event, RecommendedWatcher, RecursiveMode, Watcher, Config};
5+
use notify::{Config, Event, RecommendedWatcher, RecursiveMode, Watcher};
66
use std::path::Path;
77

88
/// Async, futures channel based event watching
@@ -24,11 +24,14 @@ fn async_watcher() -> notify::Result<(RecommendedWatcher, Receiver<notify::Resul
2424

2525
// Automatically select the best implementation for your platform.
2626
// You can also access each implementation directly e.g. INotifyWatcher.
27-
let watcher = RecommendedWatcher::new(move |res| {
28-
futures::executor::block_on(async {
29-
tx.send(res).await.unwrap();
30-
})
31-
}, Config::default())?;
27+
let watcher = RecommendedWatcher::new(
28+
move |res| {
29+
futures::executor::block_on(async {
30+
tx.send(res).await.unwrap();
31+
})
32+
},
33+
Config::default(),
34+
)?;
3235

3336
Ok((watcher, rx))
3437
}
@@ -48,4 +51,4 @@ async fn async_watch<P: AsRef<Path>>(path: P) -> notify::Result<()> {
4851
}
4952

5053
Ok(())
51-
}
54+
}

examples/debouncer_mini_custom.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{path::Path, time::Duration};
22

3-
use notify::{RecursiveMode, Config};
3+
use notify::{Config, RecursiveMode};
44
use notify_debouncer_mini::new_debouncer_opt;
55

66
/// Debouncer with custom backend and waiting for exit
@@ -18,7 +18,13 @@ fn main() {
1818
// setup debouncer
1919
let (tx, rx) = std::sync::mpsc::channel();
2020
// select backend via fish operator, here PollWatcher backend
21-
let mut debouncer = new_debouncer_opt::<_,notify::PollWatcher>(Duration::from_secs(2), None, tx, Config::default()).unwrap();
21+
let mut debouncer = new_debouncer_opt::<_, notify::PollWatcher>(
22+
Duration::from_secs(2),
23+
None,
24+
tx,
25+
Config::default(),
26+
)
27+
.unwrap();
2228

2329
debouncer
2430
.watcher()

examples/monitor_raw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use notify::{RecommendedWatcher, RecursiveMode, Watcher, Config};
1+
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
22
use std::path::Path;
33

44
fn main() {
@@ -30,4 +30,4 @@ fn watch<P: AsRef<Path>>(path: P) -> notify::Result<()> {
3030
}
3131

3232
Ok(())
33-
}
33+
}

examples/poll_sysfs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/// This example can't be demonstrated under windows, it might be relevant for network shares
44
#[cfg(not(target_os = "windows"))]
55
fn not_windows_main() -> notify::Result<()> {
6-
use notify::{PollWatcher, RecursiveMode, Watcher, Config};
6+
use notify::{Config, PollWatcher, RecursiveMode, Watcher};
77
use std::path::Path;
88
use std::time::Duration;
99

@@ -27,7 +27,7 @@ fn not_windows_main() -> notify::Result<()> {
2727
println!("watching {:?}...", paths);
2828
// configure pollwatcher backend
2929
let config = Config::default()
30-
.with_compare_contents(true) // crucial part for pseudo filesystems
30+
.with_compare_contents(true) // crucial part for pseudo filesystems
3131
.with_poll_interval(Duration::from_secs(2));
3232
let (tx, rx) = std::sync::mpsc::channel();
3333
// create pollwatcher backend

examples/watcher_kind.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::{path::Path, time::Duration};
21
use notify::*;
2+
use std::{path::Path, time::Duration};
33

44
// example of detecting the recommended watcher kind
55
fn main() {
@@ -8,9 +8,8 @@ fn main() {
88
// That way the pollwatcher specific stuff is still configured, if it should be used.
99
let mut watcher: Box<dyn Watcher> = if RecommendedWatcher::kind() == WatcherKind::PollWatcher {
1010
// custom config for PollWatcher kind
11-
// you
12-
let config = Config::default()
13-
.with_poll_interval(Duration::from_secs(1));
11+
// you
12+
let config = Config::default().with_poll_interval(Duration::from_secs(1));
1413
Box::new(PollWatcher::new(tx, config).unwrap())
1514
} else {
1615
// use default config for everything else

notify/src/config.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ impl RecursiveMode {
2222
}
2323

2424
/// Watcher Backend configuration
25-
///
25+
///
2626
/// This contains multiple settings that may relate to only one specific backend,
2727
/// such as to correctly configure each backend regardless of what is selected during runtime.
28-
///
28+
///
2929
/// ```rust
3030
/// # use std::time::Duration;
3131
/// # use notify::Config;
3232
/// let config = Config::default()
3333
/// .with_poll_interval(Duration::from_secs(2))
3434
/// .with_compare_contents(true);
3535
/// ```
36-
///
36+
///
3737
/// Some options can be changed during runtime, others have to be set when creating the watcher backend.
3838
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
3939
pub struct Config {
@@ -46,10 +46,10 @@ pub struct Config {
4646

4747
impl Config {
4848
/// For [crate::PollWatcher]
49-
///
49+
///
5050
/// Interval between each rescan attempt. This can be extremely expensive for large
5151
/// file trees so it is recommended to measure and tune accordingly.
52-
///
52+
///
5353
/// The default poll frequency is 30 seconds.
5454
pub fn with_poll_interval(mut self, dur: Duration) -> Self {
5555
self.poll_interval = dur;
@@ -62,14 +62,14 @@ impl Config {
6262
}
6363

6464
/// For [crate::PollWatcher]
65-
///
65+
///
6666
/// Optional feature that will evaluate the contents of changed files to determine if
6767
/// they have indeed changed using a fast hashing algorithm. This is especially important
6868
/// for pseudo filesystems like those on Linux under /sys and /proc which are not obligated
6969
/// to respect any other filesystem norms such as modification timestamps, file sizes, etc.
7070
/// By enabling this feature, performance will be significantly impacted as all files will
7171
/// need to be read and hashed at each `poll_interval`.
72-
///
72+
///
7373
/// This can't be changed during runtime. Off by default.
7474
pub fn with_compare_contents(mut self, compare_contents: bool) -> Self {
7575
self.compare_contents = compare_contents;
@@ -84,9 +84,9 @@ impl Config {
8484

8585
impl Default for Config {
8686
fn default() -> Self {
87-
Self {
87+
Self {
8888
poll_interval: Duration::from_secs(30),
89-
compare_contents: false
89+
compare_contents: false,
9090
}
9191
}
92-
}
92+
}

notify/src/lib.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
//! [dependencies]
77
//! notify = "6.0.0"
88
//! ```
9-
//!
9+
//!
1010
//! If you want debounced events, see [notify-debouncer-mini](https://github.com/notify-rs/notify/tree/main/notify-debouncer-mini)
1111
//! or [notify-debouncer-full](https://github.com/notify-rs/notify/tree/main/notify-debouncer-full).
12-
//!
12+
//!
1313
//! ## Features
14-
//!
14+
//!
1515
//! List of compilation features, see below for details
16-
//!
16+
//!
1717
//! - `serde` for serialization of events
1818
//! - `macos_fsevent` enabled by default, for fsevent backend on macos
1919
//! - `macos_kqueue` for kqueue backend on macos
@@ -26,66 +26,66 @@
2626
//! ```toml
2727
//! notify = { version = "6.0.0", features = ["serde"] }
2828
//! ```
29-
//!
29+
//!
3030
//! ### Crossbeam-Channel & Tokio
31-
//!
31+
//!
3232
//! By default crossbeam-channel is used internally by notify.
3333
//! This can [cause issues](https://github.com/notify-rs/notify/issues/380) when used inside tokio.
34-
//!
34+
//!
3535
//! You can disable crossbeam-channel, letting notify fallback to std channels via
36-
//!
36+
//!
3737
//! ```toml
3838
//! notify = { version = "6.0.0", default-features = false, features = ["macos_kqueue"] }
3939
//! // Alternatively macos_fsevent instead of macos_kqueue
4040
//! ```
4141
//! Note the `macos_kqueue` requirement here, otherwise no backend is available on macos.
42-
//!
42+
//!
4343
//! # Known Problems
44-
//!
44+
//!
4545
//! ### Docker with Linux on MacOS M1
46-
//!
46+
//!
4747
//! Docker on macos M1 [throws](https://github.com/notify-rs/notify/issues/423) `Function not implemented (os error 38)`.
4848
//! You have to manually use the [PollWatcher], as the native backend isn't available inside the emulation.
49-
//!
49+
//!
5050
//! ### MacOS, FSEvents and unowned files
51-
//!
51+
//!
5252
//! Due to the inner security model of FSEvents (see [FileSystemEventSecurity](https://developer.apple.com/library/mac/documentation/Darwin/Conceptual/FSEvents_ProgGuide/FileSystemEventSecurity/FileSystemEventSecurity.html)),
5353
//! some events cannot be observed easily when trying to follow files that do not
5454
//! belong to you. In this case, reverting to the pollwatcher can fix the issue,
5555
//! with a slight performance cost.
56-
//!
56+
//!
5757
//! ### Editor Behaviour
58-
//!
58+
//!
5959
//! If you rely on precise events (Write/Delete/Create..), you will notice that the actual events
6060
//! can differ a lot between file editors. Some truncate the file on save, some create a new one and replace the old one.
6161
//! See also [this](https://github.com/notify-rs/notify/issues/247) and [this](https://github.com/notify-rs/notify/issues/113#issuecomment-281836995) issues for example.
6262
//!
6363
//! ### Parent folder deletion
64-
//!
64+
//!
6565
//! If you want to receive an event for a deletion of folder `b` for the path `/a/b/..`, you will have to watch its parent `/a`.
6666
//! See [here](https://github.com/notify-rs/notify/issues/403) for more details.
67-
//!
67+
//!
6868
//! ### Pseudo Filesystems like /proc,/sys
69-
//!
69+
//!
7070
//! Some filesystems like `/proc` and `/sys` on *nix do not emit change events or use correct file change dates.
7171
//! To circumvent that problem you can use the [PollWatcher] with the `compare_contents` option.
72-
//!
72+
//!
7373
//! ### Linux: Bad File Descriptor / No space left on device
74-
//!
74+
//!
7575
//! This may be the case of running into the max-files watched limits of your user or system.
7676
//! (Files also includes folders.) Note that for recursive watched folders each file and folder inside counts towards the limit.
77-
//!
77+
//!
7878
//! You may increase this limit in linux via
7979
//! ```sh
8080
//! sudo sysctl fs.inotify.max_user_instances=8192 # example number
8181
//! sudo sysctl fs.inotify.max_user_watches=524288 # example number
8282
//! sudo sysctl -p
8383
//! ```
84-
//!
84+
//!
8585
//! Note that the [PollWatcher] is not restricted by this limitation, so it may be an alternative if your users can't increase the limit.
86-
//!
86+
//!
8787
//! # Examples
88-
//!
88+
//!
8989
//! For more examples visit the [examples folder](https://github.com/notify-rs/notify/tree/main/examples) in the repository.
9090
//!
9191
//! ```rust,no_exec

notify/src/poll.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Checks the `watch`ed paths periodically to detect changes. This implementation only uses
44
//! Rust stdlib APIs and should work on all of the platforms it supports.
55
6-
use crate::{EventHandler, RecursiveMode, Watcher, Config};
6+
use crate::{Config, EventHandler, RecursiveMode, Watcher};
77
use std::{
88
collections::HashMap,
99
path::{Path, PathBuf},
@@ -393,10 +393,10 @@ mod data {
393393
}
394394

395395
/// Polling based `Watcher` implementation.
396-
///
396+
///
397397
/// By default scans through all files and checks for changed entries based on their change date.
398398
/// Can also be changed to perform file content change checks.
399-
///
399+
///
400400
/// See [Config] for more details.
401401
#[derive(Debug)]
402402
pub struct PollWatcher {
@@ -408,10 +408,7 @@ pub struct PollWatcher {
408408

409409
impl PollWatcher {
410410
/// Create a new [PollWatcher], configured as needed.
411-
pub fn new<F: EventHandler>(
412-
event_handler: F,
413-
config: Config,
414-
) -> crate::Result<PollWatcher> {
411+
pub fn new<F: EventHandler>(event_handler: F, config: Config) -> crate::Result<PollWatcher> {
415412
let data_builder = DataBuilder::new(event_handler, config.compare_contents());
416413

417414
let poll_watcher = PollWatcher {

0 commit comments

Comments
 (0)