pub struct WallClockState { /* private fields */ }Expand description
The wall clock, as an offset from a monotonic millisecond timer.
Every method takes the current monotonic reading rather than fetching one, which is what keeps this testable without a clock at all.
Implementations§
Source§impl WallClockState
impl WallClockState
Sourcepub const fn now(&self, monotonic_ms: u64) -> Option<u32>
pub const fn now(&self, monotonic_ms: u64) -> Option<u32>
The current time in Unix seconds, or None when unknown.
Sourcepub const fn now_ms(&self, monotonic_ms: u64) -> Option<u64>
pub const fn now_ms(&self, monotonic_ms: u64) -> Option<u64>
The current time in Unix milliseconds, or None when unknown.
A clock whose offset would put it before the epoch or past what
PROP_TIME can carry reads as unknown rather than as a wrapped
value: those are only reachable from an absurd set, and reporting
a wrapped time is worse than reporting none.
Sourcepub const fn local_now(&self, monotonic_ms: u64) -> Option<u32>
pub const fn local_now(&self, monotonic_ms: u64) -> Option<u32>
The local wall-clock reading in seconds — the time shifted by the
configured zone — or None when the time is unknown.
A reading for presentation, not an instant: it does not name a point in time on its own, and nothing should send it anywhere.
Sourcepub const fn source(&self) -> Option<TimeSource>
pub const fn source(&self) -> Option<TimeSource>
Where the current reading came from, or None while unset.
Sourcepub const fn tz_offset_min(&self) -> i16
pub const fn tz_offset_min(&self) -> i16
Minutes east of UTC.
Sourcepub const fn set_tz(&mut self, minutes: i16)
pub const fn set_tz(&mut self, minutes: i16)
Set the time zone. Independent of the clock: the zone is known from commissioning, and changing it never makes the time known or unknown.
Sourcepub const fn clear(&mut self)
pub const fn clear(&mut self)
Return the device to not knowing what time it is.
The zone survives, because where the device is has not changed.
Sourcepub const fn apply(
&mut self,
epoch: u32,
monotonic_ms: u64,
source: TimeSource,
trust_receiver: bool,
) -> Update
pub const fn apply( &mut self, epoch: u32, monotonic_ms: u64, source: TimeSource, trust_receiver: bool, ) -> Update
Offer a reading from source, applying the precedence rule.
trust_receiver is PROP_GNSS_TIME_TRUST. The rule:
TimeSource::Manualalways applies. The operator is the more authoritative source by definition, including while the receiver is distrusted — distrusting the sky is why somebody would set the clock by hand.TimeSource::GnssFixapplies whenever the receiver is trusted, overwriting whatever was there. Every fix re-synchronizes the clock, which is what keeps it good over a long deployment.TimeSource::GnssRtcapplies only when trusted and the clock is unset. It is a boot-time restore, not a correction: the receiver may have re-synchronized its own RTC from a bad sky while the device was running, so it must not displace a reading that is already in hand.TimeSource::ExternalRtcapplies only when the clock is unset, for the same reason, but is not subject to the receiver trust flag — it is not the receiver.
Trait Implementations§
Source§impl Clone for WallClockState
impl Clone for WallClockState
Source§fn clone(&self) -> WallClockState
fn clone(&self) -> WallClockState
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WallClockState
impl Debug for WallClockState
Source§impl Default for WallClockState
impl Default for WallClockState
Source§impl PartialEq for WallClockState
impl PartialEq for WallClockState
impl Copy for WallClockState
impl Eq for WallClockState
impl StructuralPartialEq for WallClockState
Auto Trait Implementations§
impl Freeze for WallClockState
impl RefUnwindSafe for WallClockState
impl Send for WallClockState
impl Sync for WallClockState
impl Unpin for WallClockState
impl UnwindSafe for WallClockState
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)