1use std::cell::RefCell;
5
6use crate::{Clock, Date, Id, IdGenerator, Timestamp};
7
8#[derive(Default)]
10pub struct SeqIds {
11 n: RefCell<u64>,
12}
13
14impl IdGenerator for SeqIds {
15 fn next_id(&self) -> Id {
16 let mut n = self.n.borrow_mut();
17 *n += 1;
18 Id::new(format!("t{n}"))
19 }
20}
21
22pub struct FixedClock {
24 pub now: Timestamp,
25 pub today: Date,
26}
27
28impl Default for FixedClock {
29 fn default() -> Self {
30 Self {
31 now: Timestamp::from_millisecond(0),
32 today: Date::parse("2026-06-22").unwrap(),
33 }
34 }
35}
36
37impl Clock for FixedClock {
38 fn now(&self) -> Timestamp {
39 self.now
40 }
41 fn today(&self) -> Date {
42 self.today
43 }
44}