euv_ui/hook/use_timer/impl.rs
1use super::*;
2
3/// Inherent implementation of [`UseTimer`].
4impl UseTimer {
5 /// Creates a handle with the tick count starting at zero.
6 ///
7 /// # Arguments
8 ///
9 /// - `u32` - The period in milliseconds.
10 ///
11 /// # Returns
12 ///
13 /// - `UseTimer` - The fresh handle.
14 pub(crate) fn new(interval_ms: u32) -> Self {
15 Self {
16 ticks: Signal::create(0),
17 interval_ms,
18 }
19 }
20
21 /// Returns the tick count as a snapshot.
22 ///
23 /// # Returns
24 ///
25 /// - `u64` - How many times the timer has fired.
26 pub fn current_ticks(&self) -> u64 {
27 self.get_ticks().get()
28 }
29
30 /// Resets the tick count to zero.
31 pub fn reset(&self) {
32 self.get_ticks().set(0);
33 }
34}