pub trait Clock {
// Required methods
fn current_time(&self) -> Timestamp;
fn sleep_until<'life0, 'async_trait>(
&'life0 self,
timestamp: Timestamp,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn sleep_for<'life0, 'async_trait>(
&'life0 self,
duration: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait { ... }
}Expand description
A clock that can be used to get the current Timestamp.
Required Methods§
Sourcefn current_time(&self) -> Timestamp
fn current_time(&self) -> Timestamp
Returns the current time.
Provided Methods§
Sourcefn sleep_for<'life0, 'async_trait>(
&'life0 self,
duration: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
fn sleep_for<'life0, 'async_trait>(
&'life0 self,
duration: Duration,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
Waits for the given duration, measured against this clock.
Unlike linera_base::time::timer::sleep, this honors a simulated clock (e.g. a test
clock), so callers that sleep through it can be driven deterministically in virtual time.