coalesce

Function coalesce 

Source
pub fn coalesce<F: FnMut(MountEvent) -> WatchControl + Send + 'static>(
    delay: Duration,
    initial_event: CoalesceInitial,
    f: F,
) -> impl FnMut(MountEvent) -> WatchControl + Send + 'static
Expand description

Returns a closure that always coalesce the events with the given delay.

By passing it to 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

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")
        }
    )
);