Silk

silk/os_system_clock

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu.

Native Unix-epoch clock provider for SystemClock.

When to use

Construct OsSystemClock at a native application edge and provide it to portable code that requires &mut SystemClock. Use an ordinary fixed or scripted provider in deterministic tests.

Details

Construction is stateless and performs no host call. Each operation calls the matching libc clock function through an ordinary extern "C" declaration. A failed read, noncanonical host result, zero resolution, or unrepresentable resolution is a fatal trap because the public service has no failure channel.

Gotchas

The clock may move backwards when the operating system adjusts its external reference. Reachable operations support the current Unix-family native targets. Linux requires glibc 2.17 or later and needs no librt link. WebAssembly and no-libc selection leave this module empty.

Import as OsSystemClock with import silk.os_system_clock { OsSystemClock }.

Public declarations: 1.

OsSystemClock

pub struct OsSystemClock

A stateless native provider; construction makes no call and failed operations trap.

Associated function OsSystemClock.make

pub fn make() -> OsSystemClock

Creates a native clock provider without reading the clock or installing a default.

Implementation SystemClock for OsSystemClock

impl SystemClock for OsSystemClock

Operation now

now = OsSystemClock.impl@0.now

Operation getResolution

getResolution = OsSystemClock.impl@0.getResolution

On this page