foxglove 0.20.0

Foxglove SDK
Documentation
1
2
3
4
5
6
7
8
9
10
11
use std::time::{SystemTime, UNIX_EPOCH};

/// nanoseconds_since_epoch returns the current time in nanoseconds since the Unix epoch.
/// This is useful for setting timestamps in log messages.
pub(crate) fn nanoseconds_since_epoch() -> u64 {
    let now = SystemTime::now();
    if let Ok(duration) = now.duration_since(UNIX_EPOCH) {
        return duration.as_secs() * 1_000_000_000 + duration.subsec_nanos() as u64;
    }
    0
}