telltale_machine/
clock.rs1use serde::{Deserialize, Serialize};
4use std::time::Duration;
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct SimClock {
9 pub tick: u64,
11 pub time: Duration,
13 pub tick_duration: Duration,
15}
16
17impl SimClock {
18 #[must_use]
20 pub fn new(tick_duration: Duration) -> Self {
21 Self {
22 tick: 0,
23 time: Duration::from_secs(0),
24 tick_duration,
25 }
26 }
27
28 pub fn advance(&mut self) {
30 self.tick += 1;
31 self.time += self.tick_duration;
32 }
33}