Skip to main content

Module clock

Module clock 

Source
Expand description

Injectable time. Handlers/extensions take Dep<Clock> and call now(); tests control it via TestApp::clock().advance(..). The serve engine’s own timeouts deliberately stay on real tokio time — Clock is for DOMAIN time (rate windows, schedules, expiry), not transport timeouts.

App::new() provides a Clock::system singleton by default; provide a different one to override it. into_test() swaps in a Clock::test that TestApp::clock hands back so a test can advance or set the injected clock and observe the effect through real requests.

Structs§

Clock
An injectable source of “now”. Cloning is cheap and, for a test clock, shares the same controllable offset — so a handle handed to a test moves in lockstep with the clock the handler resolves.

Functions§

now_rfc3339
The current UTC instant as an RFC3339 string with seconds precision and a Z suffix (e.g. 2026-07-26T12:34:56Z) — the exact shape jerrycan’s datetime fields ride as (String) and the OpenAPI/fixture format uses.