pub enum Time {
Unknown,
Ahead,
At {
secs: u32,
ms: u16,
},
}Expand description
The owner’s word of its clock when it wrote the heartbeat (core §7.5): an instant, or one of the two codes that carry none. A reader reads a time as one of the three, and never the ahead time as either other.
Variants§
Unknown
All 42 bits set: the owner’s clock reads no instant the epoch codes
(freshness.v2 §2.4). It says nothing of the clock guard.
Ahead
The seconds all ones with the millisecond code 1022, the unknown
time with its last bit clear: the owner’s clock guard holds (core
§4.3, “Ahead”; freshness.v2 §2.10). It carries no instant.
At
Seconds from the deployment epoch, then milliseconds below 1000.
Implementations§
Source§impl Time
impl Time
Sourcepub fn from_code(code: u64) -> Result<Time, BodyRefusal>
pub fn from_code(code: u64) -> Result<Time, BodyRefusal>
A 42-bit code read: code for an unused millisecond code, which is
every one from 1000 up but the unknown time’s and the ahead time’s:
1000 to 1021 under any seconds, and 1022 or 1023 under seconds that
are not all ones.
§Errors
Sourcepub fn from_unix_ms(t: i128, epoch: i64) -> Option<Time>
pub fn from_unix_ms(t: i128, epoch: i64) -> Option<Time>
An instant in milliseconds since the Unix epoch, under the
deployment epoch epoch in seconds (core §7.6): None outside the
epoch’s 2^32 seconds.
Sourcepub fn written(guard: bool, at: Option<i128>, epoch: i64) -> Time
pub fn written(guard: bool, at: Option<i128>, epoch: i64) -> Time
The time an owner writes (freshness.v2 §2.4, §2.10): the ahead
time while its clock guard holds, guard, whatever its clock reads;
otherwise the instant at, in milliseconds since the Unix epoch,
under the deployment epoch epoch in seconds, or the unknown time
for a clock that reads none (None) or one the epoch does not code.
Sourcepub fn unix_ms(self, epoch: i64) -> Option<i128>
pub fn unix_ms(self, epoch: i64) -> Option<i128>
The instant in milliseconds since the Unix epoch, None for a time
that carries none: unknown or ahead.
Sourcepub fn is_instant(self) -> bool
pub fn is_instant(self) -> bool
Whether the time is an instant: the owner’s guard did not hold when it wrote the heartbeat, and its clock read a time the epoch codes.
Trait Implementations§
impl Copy for Time
impl Eq for Time
impl StructuralPartialEq for Time
Auto Trait Implementations§
impl Forget for Time
impl Freeze for Time
impl Move for Time
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnsafeUnpin for Time
impl UnwindSafe for Time
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more