use std::time::Duration;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
pub enum RecursiveMode {
Recursive,
NonRecursive,
}
impl RecursiveMode {
pub(crate) fn is_recursive(&self) -> bool {
match *self {
RecursiveMode::Recursive => true,
RecursiveMode::NonRecursive => false,
}
}
}
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
pub struct Config {
poll_interval: Option<Duration>,
compare_contents: bool,
follow_symlinks: bool,
}
impl Config {
pub fn with_poll_interval(mut self, dur: Duration) -> Self {
self.poll_interval = Some(dur);
self
}
pub fn poll_interval(&self) -> Option<Duration> {
self.poll_interval
}
pub fn with_manual_polling(mut self) -> Self {
self.poll_interval = None;
self
}
pub fn with_compare_contents(mut self, compare_contents: bool) -> Self {
self.compare_contents = compare_contents;
self
}
pub fn compare_contents(&self) -> bool {
self.compare_contents
}
pub fn with_follow_symlinks(mut self, follow_symlinks: bool) -> Self {
self.follow_symlinks = follow_symlinks;
self
}
pub fn follow_symlinks(&self) -> bool {
self.follow_symlinks
}
}
impl Default for Config {
fn default() -> Self {
Self {
poll_interval: Some(Duration::from_secs(30)),
compare_contents: false,
follow_symlinks: true,
}
}
}