lightning_liquidity/utils/
time.rs1use core::time::Duration;
4
5pub trait TimeProvider {
10 fn duration_since_epoch(&self) -> Duration;
12}
13
14#[derive(Clone, Debug)]
21#[cfg(feature = "time")]
22pub struct DefaultTimeProvider;
23
24#[cfg(feature = "time")]
25impl TimeProvider for DefaultTimeProvider {
26 fn duration_since_epoch(&self) -> Duration {
27 use std::time::{SystemTime, UNIX_EPOCH};
28 SystemTime::now().duration_since(UNIX_EPOCH).expect("system time before Unix epoch")
29 }
30}
31#[cfg(feature = "time")]
32impl core::ops::Deref for DefaultTimeProvider {
33 type Target = Self;
34 fn deref(&self) -> &Self {
35 self
36 }
37}