Silk

silk/os_system_clock

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 crosses only its matching native clock intrinsic. 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 and evaluator hosts. Linux requires glibc 2.17 or later and needs no librt link. Direct WebAssembly rejects reachable operations and does not add an ambient time import.

Import as OsSystemClock with import silk.os_system_clock.

Public declarations: 2.

OsSystemClock

pub struct OsSystemClock

A stateless Unix-family native provider of Unix-epoch time. A failed, invalid, or unrepresentable clock result traps. Direct WebAssembly does not support a reachable operation on this provider.

make

pub fn make() -> OsSystemClock

Creates a native system-clock provider without reading the clock or installing it as a default.

Implementation SystemClock.SystemClock for OsSystemClock

impl SystemClock.SystemClock for OsSystemClock

Operation now

now = OsSystemClock.now

Operation getResolution

getResolution = OsSystemClock.getResolution

On this page