feat: current state
This commit is contained in:
+17
-1
@@ -1 +1,17 @@
|
||||
pub trait Clock {} pub struct SystemClock;
|
||||
use async_trait::async_trait;
|
||||
use std::time::{Duration, Instant};
|
||||
#[async_trait]
|
||||
pub trait Clock: Send + Sync {
|
||||
fn now(&self) -> Instant;
|
||||
async fn sleep(&self, duration: Duration);
|
||||
}
|
||||
pub struct SystemClock;
|
||||
#[async_trait]
|
||||
impl Clock for SystemClock {
|
||||
fn now(&self) -> Instant {
|
||||
Instant::now()
|
||||
}
|
||||
async fn sleep(&self, duration: Duration) {
|
||||
tokio::time::sleep(duration).await;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user