Skip to main content

Crate ppoppo_clock

Crate ppoppo_clock 

Source
Expand description

§ppoppo-clock

The time port of the ppoppo ecosystem: one Clock (“what time is it?”) and one Timer (“wake me in N ms”), injected wherever code needs time, so no surface reads the ambient system clock directly.

§Usage

use ppoppo_clock::ArcClock;

fn stamp(clock: &ArcClock) -> i64 {
    clock.now_unix_millis()
}
FeatureArm
nativenative::{NativeClock, NativeTimer, system_tz} — the Tokio runtime
wasmwasm::{WasmClock, WasmTimer, browser_local_tz} — the browser event loop (on wasm32 only)
mockmock::{FrozenClock, MockClock, AdvanceableTimer, frozen_at, mock_pair} — deterministic tests

With no feature the crate is the two traits, their Arc aliases and the family’s one future alias, BoxFuture (Send everywhere but wasm32) — no runtime, no IO. The port’s value types are jiff’s (Timestamp, Zoned, tz::TimeZone, civil::Date), re-exported as ppoppo_clock::jiff so a consumer names one version of them.

Zone math is arm-independent: jiff’s bundled tzdb makes Clock::now_in and Clock::today_in provided methods, so each arm implements only Clock::now. jiff is the Rust realization of the TC39 Temporal model (Timestamp ≙ Temporal.Instant, Zoned ≙ Temporal.ZonedDateTime, civil::Date ≙ Temporal.PlainDate), identically on every arm.

§Versioning

STABLE VOCABULARY. Nameable by any application and semver-versioned on its own: the port’s signature changes only on a major version. Every ppoppo face takes and returns these traits, so a consumer holding an ArcClock built here hands the same value to each face.

Read CHANGELOG.md for what actually moved.

§License

MIT OR Apache-2.0

Re-exports§

pub use jiff;

Modules§

mockmock
Deterministic test arm: a frozen clock, a settable clock, and a timer whose sleeps resolve only when that clock is advanced.
nativenative
Tokio arm: the system wall clock and a Tokio-backed timer.

Traits§

Clock
Wall-clock readouts. Single port for “what time is it?” across all surfaces.
Timer
Async scheduling primitive. Single port for “wait N ms” / “yield event-loop tick”.

Type Aliases§

ArcClock
A shared Clock — the shape every ppoppo constructor takes.
ArcTimer
A shared Timer — the shape every ppoppo constructor takes.
BoxFutureNon-WebAssembly
A boxed future — the one future alias of the ppoppo family. Send on every target but wasm32, where the browser runs one thread and a JsFuture is never Send; a port held as dyn returns it, so one signature serves both targets.