mount_watcher/
lib.rs

1//! Get notified when a filesystem is mounted/unmounted!
2//!
3//! # Getting started
4//!
5//! The entrypoint of this library is [`MountWatcher`], which enables the detection of
6//! mount/unmount events.
7//!
8//! ```
9//! use mount_watcher::{MountWatcher, WatchControl};
10//!
11//! let watch = MountWatcher::new(|event| {
12//!     if event.initial {
13//!         println!("initial mount points: {:?}", event.mounted);
14//!     } else {
15//!         println!("new mounts: {:?}", event.mounted);
16//!         println!("removed mounts: {:?}", event.unmounted);
17//!     }
18//!     WatchControl::Continue
19//! });
20//! // store the watcher somewhere (it will stop on drop)
21//! ```
22//!
23//! # Advanced features
24//!
25//! For more advanced use cases, have a look at [`WatchControl::Coalesce`] and [`callback::coalesce`].
26
27pub mod callback;
28pub mod mount;
29pub mod watch;
30
31pub use watch::{MountEvent, MountWatcher, WatchControl};
32
33#[cfg(not(target_os = "linux"))]
34compile_error!("only Linux is supported");