use std::time::{SystemTime, UNIX_EPOCH};
pub trait Clock: Send + Sync {
fn now_ms(&self) -> u64;
}
#[derive(Debug, Clone, Copy, Default)]
pub struct SystemClock;
impl Clock for SystemClock {
fn now_ms(&self) -> u64 {
SystemTime::now()
.duration_since(UNIX_EPOCH)
.map(|d| d.as_millis() as u64)
.unwrap_or(0)
}
}
pub trait SecretStore: Send + Sync {
fn get(&self, name: &str) -> Option<String>;
}
#[derive(Debug, Clone, Copy, Default)]
pub struct EnvSecrets;
impl SecretStore for EnvSecrets {
fn get(&self, name: &str) -> Option<String> {
std::env::var(name).ok().filter(|v| !v.is_empty())
}
}