Skip to main content

PlatformTime

Trait PlatformTime 

Source
pub trait PlatformTime {
    // Required methods
    fn time_now_ms() -> u64;
    fn time_since_epoch_secs() -> u32;
    fn time_since_epoch_nanos() -> u32;
}
Expand description

Wall-clock / system time.

Used for logging timestamps and z_time_now_as_str(). On bare-metal without an RTC, return monotonic time or zeros.

The two-function time_since_epoch_* split (instead of returning a struct) was chosen to match the shape that zenoh-pico’s C headers want across the FFI boundary — 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.

Required Methods§

Source

fn time_now_ms() -> u64

Returns system time in milliseconds.

Source

fn time_since_epoch_secs() -> u32

Seconds component of wall-clock time since the Unix epoch.

Source

fn time_since_epoch_nanos() -> u32

Sub-second nanoseconds component of wall-clock time since the Unix epoch (i.e. the nanosecond remainder after the seconds are stripped; always in 0..1_000_000_000).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl PlatformTime for CffiPlatform

Implementors§