notify_types/
debouncer_full.rs

1use std::ops::{Deref, DerefMut};
2
3#[cfg(feature = "web-time")]
4use web_time::Instant;
5
6#[cfg(not(feature = "web-time"))]
7use std::time::Instant;
8
9use crate::event::Event;
10
11/// A debounced event is emitted after a short delay.
12#[derive(Debug, Clone, PartialEq, Eq)]
13pub struct DebouncedEvent {
14    /// The original event.
15    pub event: Event,
16
17    /// The time at which the event occurred.
18    pub time: Instant,
19}
20
21impl DebouncedEvent {
22    pub fn new(event: Event, time: Instant) -> Self {
23        Self { event, time }
24    }
25}
26
27impl Deref for DebouncedEvent {
28    type Target = Event;
29
30    fn deref(&self) -> &Self::Target {
31        &self.event
32    }
33}
34
35impl DerefMut for DebouncedEvent {
36    fn deref_mut(&mut self) -> &mut Self::Target {
37        &mut self.event
38    }
39}