1use std::time::{SystemTime, UNIX_EPOCH};
9
10pub trait Clock: Send + Sync {
11 fn now_ms(&self) -> u64;
12}
13
14#[derive(Debug, Clone, Copy, Default)]
15pub struct SystemClock;
16
17impl Clock for SystemClock {
18 fn now_ms(&self) -> u64 {
19 SystemTime::now()
20 .duration_since(UNIX_EPOCH)
21 .map(|d| d.as_millis() as u64)
22 .unwrap_or(0)
23 }
24}
25
26pub trait SecretStore: Send + Sync {
29 fn get(&self, name: &str) -> Option<String>;
30}
31
32#[derive(Debug, Clone, Copy, Default)]
33pub struct EnvSecrets;
34
35impl SecretStore for EnvSecrets {
36 fn get(&self, name: &str) -> Option<String> {
37 std::env::var(name).ok().filter(|v| !v.is_empty())
38 }
39}