1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Callback helpers.
use Duration;
use crate::;
/// How to handle the initial event, which contains the list of mount points that
/// have been detected when the watcher has started.
/// Returns a closure that always coalesce the events with the given delay.
///
/// By passing it to [`MountWatcher::new`](crate::MountWatcher::new), you will only
/// get events at the specified time interval.
///
/// # Initial event
///
/// The first, initial event is handled according to the value of `initial_event`.
/// It can be useful to use `PassImmediately` to get a first list of the mount points
/// as soon as possible.
///
/// # Example
///
/// ```no_run
/// use std::time::Duration;
/// use mount_watcher::MountWatcher;
/// use mount_watcher::callback::{coalesce, CoalesceInitial};
///
/// let watch = MountWatcher::new(
/// coalesce(
/// Duration::from_secs(5),
/// CoalesceInitial::PassImmediately,
/// |event| {
/// todo!("handle event")
/// }
/// )
/// );
/// ```
+ Send + 'static