Flexweave
API Reference

Clock

Caller-defined clock units and runtime time conversion helpers.

Public exports:

  • ClockUnits
  • Clock
  • FixedStepClock
  • RealtimeClock
  • RealtimeClockAccumulator

ClockUnits is u64. Flexweave does not assign real-world meaning to units.

Clock

Clock converts caller-owned steps into ClockUnits through units_for.

TypeStep typeBehavior
FixedStepClocku64Multiplies step count by configured units per step.
RealtimeClockDurationConverts elapsed realtime into whole units.
RealtimeClockAccumulatorDurationConverts realtime and preserves fractional remainder.

FixedStepClock

APIBehavior
newCreates a fixed-step clock.
units_per_stepReturns configured units per step.
units_forSaturating multiplication of step and scale.

RealtimeClock

FixedStepClock returns a fixed number of units for each step.

RealtimeClock converts Duration values to units based on the caller's scale. The conversion is stateless and floors fractional units for each call.

RealtimeClockAccumulator accumulates fractional realtime progress across frames so repeated sub-unit deltas eventually advance mechanics.

APIBehavior
RealtimeClock::newCreates a stateless realtime clock.
units_per_secondReturns configured scale.
RealtimeClockAccumulator::newCreates an accumulator from units per second.
from_clockCreates an accumulator from an existing realtime clock.
clockReturns the underlying realtime clock.
advanceReturns whole units and retains fractional remainder.
resetDrops retained fractional remainder.

On this page