pub struct NtpTimestamp(pub u64);Expand description
NTP uses a 64-bit timestamp: 32-bit seconds since 1900-01-01 + 32-bit fraction. Stored as a single u64 for arithmetic efficiency. Upper 32 bits = seconds, lower 32 bits = fractional seconds.
Tuple Fields§
§0: u64Implementations§
Source§impl NtpTimestamp
impl NtpTimestamp
pub const ZERO: Self
Sourcepub fn new(seconds: u32, fraction: u32) -> Self
pub fn new(seconds: u32, fraction: u32) -> Self
Create from separate seconds (since NTP epoch) and fraction parts.
Sourcepub fn from_system_time(time: SystemTime) -> Self
pub fn from_system_time(time: SystemTime) -> Self
Convert from a SystemTime.
Sourcepub fn to_system_time(self) -> SystemTime
pub fn to_system_time(self) -> SystemTime
Convert to a SystemTime.
Sourcepub fn from_bytes(bytes: [u8; 8]) -> Self
pub fn from_bytes(bytes: [u8; 8]) -> Self
Deserialize from 8-byte big-endian wire format.
Trait Implementations§
Source§impl Clone for NtpTimestamp
impl Clone for NtpTimestamp
Source§fn clone(&self) -> NtpTimestamp
fn clone(&self) -> NtpTimestamp
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 NtpTimestamp
Source§impl Debug for NtpTimestamp
impl Debug for NtpTimestamp
Source§impl Default for NtpTimestamp
impl Default for NtpTimestamp
Source§fn default() -> NtpTimestamp
fn default() -> NtpTimestamp
Returns the “default value” for a type. Read more
Source§impl Display for NtpTimestamp
impl Display for NtpTimestamp
impl Eq for NtpTimestamp
Source§impl Hash for NtpTimestamp
impl Hash for NtpTimestamp
Source§impl Ord for NtpTimestamp
impl Ord for NtpTimestamp
Source§fn cmp(&self, other: &NtpTimestamp) -> Ordering
fn cmp(&self, other: &NtpTimestamp) -> 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 NtpTimestamp
impl PartialEq for NtpTimestamp
Source§fn eq(&self, other: &NtpTimestamp) -> bool
fn eq(&self, other: &NtpTimestamp) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for NtpTimestamp
impl PartialOrd for NtpTimestamp
impl StructuralPartialEq for NtpTimestamp
Auto Trait Implementations§
impl Freeze for NtpTimestamp
impl RefUnwindSafe for NtpTimestamp
impl Send for NtpTimestamp
impl Sync for NtpTimestamp
impl Unpin for NtpTimestamp
impl UnsafeUnpin for NtpTimestamp
impl UnwindSafe for NtpTimestamp
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