Skip to main content

PlatformTime

Trait PlatformTime 

Source
pub trait PlatformTime {
    // Required methods
    fn time_now_ns() -> u64;
    fn wall_clock_state() -> WallClockState;
}
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. 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.

Source

fn wall_clock_state() -> WallClockState

What PlatformTime::time_now_ns means right now, the C ABI’s nros_platform_wall_clock_state. REQUIRED, with no default: a port that cannot say must not be answered for.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl PlatformTime for CffiPlatform

Implementors§