Skip to main content

cloud_sdk/operation/permit/
clock.rs

1//! Caller-owned time observations at permit dispatch.
2
3use super::PermitTimestamp;
4
5/// Time source sampled inside permit execution immediately before dispatch.
6///
7/// The SDK owns no clock. Implementations must provide trustworthy Unix time
8/// and must not move backward. Send-async execution additionally requires a
9/// `Sync` clock because the returned future may move between threads.
10pub trait PermitClock {
11    /// Returns the current caller-observed time.
12    fn now(&self) -> PermitTimestamp;
13}
14
15impl<F> PermitClock for F
16where
17    F: Fn() -> PermitTimestamp,
18{
19    fn now(&self) -> PermitTimestamp {
20        self()
21    }
22}