pub struct NTP64(pub u64);
Expand description
A NTP 64-bits format as specified in RFC-5909
The first 32-bits part is the number of second since the EPOCH of the physical clock,
and the second 32-bits part is the fraction of second.
In case it’s part of a crate::Timestamp
generated by an crate::HLC
the last few bits are replaced
by the HLC logical counter. The size of this counter currently hard-coded in crate::CSIZE
.
Note that this timestamp in actually similar to a std::time::Duration
, as it doesn’t
define an EPOCH. Only the NTP64::to_system_time()
and std::fmt::Display::fmt()
operations assume that
it’s relative to UNIX_EPOCH (1st Jan 1970) to display the timpestamp in RFC-3339 format.
Tuple Fields§
§0: u64
Implementations§
Source§impl NTP64
impl NTP64
Sourcepub fn subsec_nanos(&self) -> u32
pub fn subsec_nanos(&self) -> u32
Returns the 32-bits fraction of second part converted to nanoseconds.
Sourcepub fn to_duration(self) -> Duration
pub fn to_duration(self) -> Duration
Convert to a Duration
.
Sourcepub fn to_system_time(self) -> SystemTime
pub fn to_system_time(self) -> SystemTime
Convert to a SystemTime
(making the assumption that this NTP64 is relative to UNIX_EPOCH
).
Trait Implementations§
Source§impl AddAssign<u64> for NTP64
impl AddAssign<u64> for NTP64
Source§fn add_assign(&mut self, other: u64)
fn add_assign(&mut self, other: u64)
+=
operation. Read moreSource§impl<'de> Deserialize<'de> for NTP64
impl<'de> Deserialize<'de> for NTP64
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<NTP64, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<NTP64, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for NTP64
impl Ord for NTP64
Source§impl PartialOrd for NTP64
impl PartialOrd for NTP64
Source§impl Serialize for NTP64
impl Serialize for NTP64
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl SubAssign<u64> for NTP64
impl SubAssign<u64> for NTP64
Source§fn sub_assign(&mut self, other: u64)
fn sub_assign(&mut self, other: u64)
-=
operation. Read more