Crate gametime

Source
Expand description

This crate provides TimeSpan and TimeStamp types for working with time in ergonomic way in game engines.

TimeSpan is a type that represents a time span in nanoseconds. Similar to std::time::Duration, but smaller and thus faster.

TimeStamp is a type that represents a point in time in nanoseconds, relative to reference point.

Clock is a type that represents a clock to measure time and steps.

Frequency and FrequencyTicker allow exact frequency ticker using rational values.

§Features

  • std - enables std support, including Clock and ClockStep types.
  • global_reference - enables [TimeStamp::now] function to get time stamp relative to global reference point that is initialized by first call to [TimeStamp::now].
  • serde - enables serde support for TimeSpan and Frequency.

Macros§

timespan
Converts human-readable expression into TimeSpan.
ts
Converts human-readable expression into TimeSpan. Shortcut for timespan!.

Structs§

Clock
Time measuring device. Uses system monotonic clock counter and yields ClockSteps for each step.
ClockRate
Produces clock steps with given rate. Uses external time span to advance the clock, usually from some Clock.
ClockStep
Result of Clock step. Contains time stamp corresponding to “now” and time span since previous step.
Frequency
Represents frequency as a rational number.
FrequencyTicker
Ticker with the given frequency.
FrequencyTickerIter
Iterator over ticks from FrequencyTicker.
TimeSpan
An interval in between time stamps. This type is used to represent durations with nanosecond precision.
TimeStamp
A fixed point in time relative to a reference point in time.

Traits§

FrequencyNumExt
This trait adds methods to integers to convert values into Frequencys.
TimeSpanNumExt
This trait adds methods to integers to convert values into TimeSpans.