pub struct SystemInstant { /* private fields */ }Expand description
A monotonic Instant paired with the wall-clock time it was taken at.
Sans-I/O protocol code measures time with a monotonic Instant, but RTCP timestamps
and NTP fields need wall-clock time. Capturing both once lets either be derived from the
other later without re-reading the (non-monotonic) system clock.
Implementations§
Source§impl SystemInstant
impl SystemInstant
Sourcepub fn now() -> Self
pub fn now() -> Self
Captures the current monotonic instant together with the current wall-clock time.
Sourcepub fn instant(&self, duration_since_unix_epoch: Duration) -> Instant
pub fn instant(&self, duration_since_unix_epoch: Duration) -> Instant
Converts a Unix-epoch duration back into the monotonic Instant it corresponds to.
Sourcepub fn duration_since_unix_epoch(&self) -> Duration
pub fn duration_since_unix_epoch(&self) -> Duration
The wall-clock time, as a duration since the Unix epoch, captured at construction.
Sourcepub fn unix(&self, now: Instant) -> Duration
pub fn unix(&self, now: Instant) -> Duration
Converts the monotonic now into wall-clock time as a duration since the Unix epoch.
Sourcepub fn ntp(&self, now: Instant) -> u64
pub fn ntp(&self, now: Instant) -> u64
Converts the monotonic now into a 64-bit NTP timestamp, as RTCP Sender Reports carry.
Sourcepub fn unix2ntp(duration_since_unix_epoch: Duration) -> u64
pub fn unix2ntp(duration_since_unix_epoch: Duration) -> u64
Converts a Unix-epoch duration into a 64-bit NTP timestamp.
The result is seconds since the NTP epoch (1900-01-01) in the high 32 bits and a binary fraction of a second in the low 32.
Sourcepub fn ntp2unix(ntp: u64) -> Duration
pub fn ntp2unix(ntp: u64) -> Duration
Converts a 64-bit NTP timestamp into a duration since the Unix epoch.
The inverse of Self::unix2ntp.
Trait Implementations§
Source§impl Clone for SystemInstant
impl Clone for SystemInstant
Source§fn clone(&self) -> SystemInstant
fn clone(&self) -> SystemInstant
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more