Expand description
The time source the runtime reads, so that time is an input you control.
Every decision the runtime makes from elapsed time reads a Clock:
- temporal patterns (“sustained for 5 s”);
- phase durations;
- resolver cache expiry;
- the
session:timing signals (silence_ms,elapsed_ms, …); - mutation-journal timestamps.
In production that is the SystemClock. In a test or a replay it is a
ManualClock you advance yourself, so the same inputs give the same
decisions every run. replay_session
drives one from the recorded frame timestamps.
The clock travels with State: every clone and
delta view shares it, so a component that can read state can read the
time without another parameter.
use std::sync::Arc;
use std::time::Duration;
use gemini_adk_rs::clock::{Clock, ManualClock};
use gemini_adk_rs::State;
let clock = Arc::new(ManualClock::new());
let state = State::new().with_clock(clock.clone());
let t0 = state.clock().now();
clock.advance(Duration::from_secs(5));
assert_eq!(state.clock().now() - t0, Duration::from_secs(5));Structs§
- Manual
Clock - A clock that moves only when told to.
- System
Clock - The real clock:
Instant::nowandSystemTime::now.
Traits§
- Clock
- A source of monotonic and wall-clock time.
Functions§
- system_
clock - The default clock: a shared
SystemClock.
Type Aliases§
- Shared
Clock - A shared, dynamically dispatched clock.