Function get_epoch_timestamp_ns

Source
pub fn get_epoch_timestamp_ns() -> u64
Expand description

Get epoch timestamp for external systems, APIs, and persistence

This returns nanoseconds since Unix epoch (January 1, 1970 UTC). Use this for any timestamp that needs to:

  • Be stored in databases
  • Be sent to external APIs
  • Be used in JWT tokens
  • Be logged for debugging
  • Survive program restarts

ยงClock Error Behavior

When the system clock is broken (e.g., time went backwards):

  • With panic-on-clock-error feature: Panics immediately for fail-fast behavior
  • Without feature: Returns a sentinel value (u64::MAX - 1 second) to indicate error

Enable the feature for production HFT systems where incorrect timestamps are unacceptable.