Function get_timestamp_ns_result

Source
pub fn get_timestamp_ns_result() -> Result<u64, SystemTimeError>
Expand description

Get current timestamp in nanoseconds with proper error handling

Returns a Result that properly propagates SystemTimeError instead of hiding failures with sentinel values. This is the recommended function for HFT systems where timestamp accuracy is critical.

§Errors

Returns SystemTimeError if the system clock has moved backwards or if there are other system time issues.

§Example

use rusty_common::time::get_timestamp_ns_result;

match get_timestamp_ns_result() {
    Ok(timestamp) => println!("Current time: {} ns", timestamp),
    Err(e) => {
        eprintln!("System clock error: {}", e);
        // Handle the error appropriately for your use case
    }
}