Skip to main content

PlatformTime

Trait PlatformTime 

Source
pub trait PlatformTime {
    // Required method
    fn time_now_ns() -> u64;
}
Expand description

Wall-clock / system time.

Used for logging timestamps and z_time_now_as_str(). On bare-metal without an RTC, return 0.

ONE method for one fact, matching nros_platform_time_now_ns in the C ABI (issue 0532 item 5). It replaced time_now_ms + time_since_epoch_secs + time_since_epoch_nanos.

The old doc justified the split by zenoh-pico’s FFI shape: “zpico-platform- shim forwards each of these directly to a _z_time_* symbol, so collapsing them into a Rust struct would require the shim to decompose the struct on every call.” That argument was against a STRUCT, and it still holds — but a single u64 is not a struct. The shim now takes one value and derives the pair with a divide and a remainder, which is both cheaper than two FFI calls and, unlike them, cannot tear across a second boundary.

Required Methods§

Source

fn time_now_ns() -> u64

Wall-clock nanoseconds since the Unix epoch, or 0 if this platform has no real-time clock.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§