Skip to main content

aura_agent/runtime/effects/
time.rs

1use super::AuraEffectSystem;
2use async_trait::async_trait;
3use aura_core::effects::{
4    LogicalClockEffects, OrderClockEffects, PhysicalTimeEffects, TimeEffects, TimeError,
5};
6
7// Time effects backed by the production physical clock handler.
8#[async_trait]
9impl PhysicalTimeEffects for AuraEffectSystem {
10    async fn physical_time(&self) -> Result<aura_core::time::PhysicalTime, TimeError> {
11        self.time_handler.physical_time().await
12    }
13
14    async fn sleep_ms(&self, ms: u64) -> Result<(), TimeError> {
15        self.time_handler.sleep_ms(ms).await;
16        Ok(())
17    }
18}
19
20#[async_trait]
21impl TimeEffects for AuraEffectSystem {}
22
23#[async_trait]
24impl LogicalClockEffects for AuraEffectSystem {
25    async fn logical_advance(
26        &self,
27        observed: Option<&aura_core::time::VectorClock>,
28    ) -> Result<aura_core::time::LogicalTime, TimeError> {
29        self.logical_clock.logical_advance(observed).await
30    }
31
32    async fn logical_now(&self) -> Result<aura_core::time::LogicalTime, TimeError> {
33        self.logical_clock.logical_now().await
34    }
35}
36
37#[async_trait]
38impl OrderClockEffects for AuraEffectSystem {
39    async fn order_time(&self) -> Result<aura_core::time::OrderTime, TimeError> {
40        self.order_clock.order_time().await
41    }
42}