pub struct WallTime { /* private fields */ }Expand description
Wall-clock instant carrying the full EPICS nsec (1 ns precision) on every
platform.
Stored as a Duration since the Unix epoch (integer seconds + nanos), so
a wire-sourced epicsTimeStamp.nsec survives a store→serve round-trip
exactly. std::time::SystemTime is backed by FILETIME on Windows and
only resolves to 100 ns, which truncated the low nanosecond digits of an
externally supplied timestamp (a PVA PUT, a gateway pass-through, a
Q:time:tag nsec split); WallTime keeps integers end-to-end and never
truncates. On Linux/macOS SystemTime already holds 1 ns, so this only
changes behaviour on Windows.
Implementations§
Source§impl WallTime
impl WallTime
Sourcepub const UNIX_EPOCH: Self
pub const UNIX_EPOCH: Self
The Unix epoch (1970-01-01T00:00:00Z) — the zero instant.
Sourcepub fn now() -> Self
pub fn now() -> Self
Current wall-clock time from the OS clock.
On Windows the OS clock itself is 100 ns-granular (the same limit C
EPICS hits), so “now” loses no precision relative to C; only an
externally supplied sub-100 ns nsec would, and that arrives through
WallTime::from_unix.
Sourcepub fn from_unix(secs: u64, nanos: u32) -> Self
pub fn from_unix(secs: u64, nanos: u32) -> Self
Build from an integer (unix_seconds, nanoseconds) pair. nanos at or
above 1e9 carries into seconds, matching Duration::new.
Sourcepub fn since_unix_epoch(self) -> Duration
pub fn since_unix_epoch(self) -> Duration
Time elapsed since the Unix epoch as a Duration (1 ns precision).
Sourcepub fn subsec_nanos(self) -> u32
pub fn subsec_nanos(self) -> u32
Sub-second nanoseconds in 0..1_000_000_000.
Sourcepub fn saturating_sub(self, d: Duration) -> Self
pub fn saturating_sub(self, d: Duration) -> Self
This instant minus d, saturating at WallTime::UNIX_EPOCH rather
than panicking on underflow.
Trait Implementations§
impl Copy for WallTime
impl Eq for WallTime
Source§impl From<SystemTime> for WallTime
impl From<SystemTime> for WallTime
Source§fn from(t: SystemTime) -> Self
fn from(t: SystemTime) -> Self
Times before the Unix epoch clamp to WallTime::UNIX_EPOCH
(unwrap_or_default), matching the previous
duration_since(UNIX_EPOCH).unwrap_or(ZERO) behaviour at the
snapshot/codec boundaries.
Source§impl From<WallTime> for SystemTime
impl From<WallTime> for SystemTime
Source§fn from(t: WallTime) -> Self
fn from(t: WallTime) -> Self
For display/formatting interop (e.g. chrono). On Windows this
re-introduces the platform’s 100 ns SystemTime granularity, so use
the integer accessors (WallTime::unix_secs / WallTime::subsec_nanos)
when the full nsec must be preserved.