pub struct NtpDuration(/* private fields */);Expand description
High-resolution signed duration for offset/delay calculations. Stored as signed nanoseconds in i128 for sub-nanosecond precision with the lower 32 bits representing fractional nanoseconds.
Implementations§
Source§impl NtpDuration
impl NtpDuration
pub const ZERO: Self
Sourcepub fn from_nanos(nanos: i64) -> Self
pub fn from_nanos(nanos: i64) -> Self
Create from whole nanoseconds.
Sourcepub fn from_seconds_f64(secs: f64) -> Self
pub fn from_seconds_f64(secs: f64) -> Self
Create from seconds as f64.
Sourcepub fn from_millis(ms: i64) -> Self
pub fn from_millis(ms: i64) -> Self
Create from milliseconds.
Sourcepub fn to_seconds_f64(self) -> f64
pub fn to_seconds_f64(self) -> f64
Convert to seconds as f64.
Sourcepub fn to_millis_f64(self) -> f64
pub fn to_millis_f64(self) -> f64
Convert to milliseconds as f64.
Sourcepub fn from_ntp_short(raw: u32) -> Self
pub fn from_ntp_short(raw: u32) -> Self
Create from NTP short format (16.16 fixed-point, in seconds).
Sourcepub fn to_ntp_short(self) -> u32
pub fn to_ntp_short(self) -> u32
Convert to NTP short format (16.16 fixed-point, in seconds). Only works for non-negative durations.
Sourcepub fn between(a: NtpTimestamp, b: NtpTimestamp) -> Self
pub fn between(a: NtpTimestamp, b: NtpTimestamp) -> Self
Compute the difference between two NTP timestamps as a duration.
Trait Implementations§
Source§impl Add for NtpDuration
impl Add for NtpDuration
Source§impl Clone for NtpDuration
impl Clone for NtpDuration
Source§fn clone(&self) -> NtpDuration
fn clone(&self) -> NtpDuration
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for NtpDuration
Source§impl Debug for NtpDuration
impl Debug for NtpDuration
Source§impl Default for NtpDuration
impl Default for NtpDuration
Source§fn default() -> NtpDuration
fn default() -> NtpDuration
Returns the “default value” for a type. Read more
Source§impl Display for NtpDuration
impl Display for NtpDuration
Source§impl Div<i64> for NtpDuration
impl Div<i64> for NtpDuration
impl Eq for NtpDuration
Source§impl Hash for NtpDuration
impl Hash for NtpDuration
Source§impl Neg for NtpDuration
impl Neg for NtpDuration
Source§impl Ord for NtpDuration
impl Ord for NtpDuration
Source§fn cmp(&self, other: &NtpDuration) -> Ordering
fn cmp(&self, other: &NtpDuration) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for NtpDuration
impl PartialEq for NtpDuration
Source§fn eq(&self, other: &NtpDuration) -> bool
fn eq(&self, other: &NtpDuration) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for NtpDuration
impl PartialOrd for NtpDuration
impl StructuralPartialEq for NtpDuration
Auto Trait Implementations§
impl Freeze for NtpDuration
impl RefUnwindSafe for NtpDuration
impl Send for NtpDuration
impl Sync for NtpDuration
impl Unpin for NtpDuration
impl UnsafeUnpin for NtpDuration
impl UnwindSafe for NtpDuration
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more