pub struct Rtc { /* private fields */ }Expand description
Last-Known-Good UTC Time tracking for the device (Matter Core spec).
The persisted utc_us field is the spec-mandated stored
fallback used by cert path validation when no live time
synchronization is available; it is seeded from
crate::utils::epoch::FIRMWARE_BUILD_MATTER_US on a
freshly-flashed device.
anchor, granularity, and source are volatile — they
describe the current monotonic-clock anchoring around the most
recent [Matter::set_utc_time] call. After reboot, anchor is
None (no live current-time tracking is active), so the TimeSync
cluster reports UTCTime = Null, Granularity = NoTimeGranularity
and TimeSource = None (per spec) — while
utc_us still carries the persisted LKG value for cert validity.
Implementations§
Source§impl Rtc
impl Rtc
pub fn reset_persist<S>(
&mut self,
store: S,
buf: &mut [u8],
) -> Result<(), Error>where
S: KvBlobStore,
pub fn load_persist<S>(&mut self, kv: S, buf: &mut [u8]) -> Result<(), Error>where
S: KvBlobStore,
Sourcepub fn trusted_time_source(&self) -> Option<TrustedTimeSource>
pub fn trusted_time_source(&self) -> Option<TrustedTimeSource>
Return the configured Trusted Time Source, or None if unset
(Matter Core spec).
Sourcepub fn set_trusted_time_source<E>(
&mut self,
source: Option<TrustedTimeSource>,
change_notifier: &dyn AttrChangeNotifier,
event_emitter: E,
) -> Result<(), Error>where
E: EventEmitter,
pub fn set_trusted_time_source<E>(
&mut self,
source: Option<TrustedTimeSource>,
change_notifier: &dyn AttrChangeNotifier,
event_emitter: E,
) -> Result<(), Error>where
E: EventEmitter,
Install or clear the Trusted Time Source (Matter Core spec).
fab_idx is the fabric performing the change —
recorded so that fabric removal can clear an entry it owns.
Sourcepub fn set_trusted_time_source_persist<S, E>(
&mut self,
source: Option<TrustedTimeSource>,
persist: &mut Persist<S>,
change_notifier: &dyn AttrChangeNotifier,
event_emitter: E,
) -> Result<(), Error>where
S: KvBlobStoreAccess,
E: EventEmitter,
pub fn set_trusted_time_source_persist<S, E>(
&mut self,
source: Option<TrustedTimeSource>,
persist: &mut Persist<S>,
change_notifier: &dyn AttrChangeNotifier,
event_emitter: E,
) -> Result<(), Error>where
S: KvBlobStoreAccess,
E: EventEmitter,
Install or clear the Trusted Time Source (Matter Core spec).
fab_idx is the fabric performing the change —
recorded so that fabric removal can clear an entry it owns.
source = None clears any existing entry.
Updates in-memory state, persists under
crate::persist::TRUSTED_TIME_SOURCE_KEY, and notifies
subscribers of the TrustedTimeSource attribute change.
Sourcepub fn utc_time(&self) -> UtcTime
pub fn utc_time(&self) -> UtcTime
Return the current UTC time if available, or the persisted Last-Known-Good UTC Time otherwise.
Sourcepub fn utc_time_granularity(&self) -> GranularityEnum
pub fn utc_time_granularity(&self) -> GranularityEnum
Return the Granularity reported on the wire for the TimeSync
cluster’s Granularity attribute, derived from the most
recent Self::set_utc_time (with the spec-required
step-down and floor already applied) — or NoTimeGranularity
if no set_utc_time has been called since boot (per
the spec, which forbids NoTimeGranularity only while
UTCTime ≠ Null).
Sourcepub fn utc_time_source(&self) -> TimeSourceEnum
pub fn utc_time_source(&self) -> TimeSourceEnum
Return the TimeSource reported on the wire for the TimeSync
cluster’s TimeSource attribute — None until the first
Self::set_utc_time (per spec).
Sourcepub fn set_utc_time(
&mut self,
utc_us: u64,
granularity: GranularityEnum,
source: TimeSourceEnum,
change_notifier: &dyn AttrChangeNotifier,
) -> bool
pub fn set_utc_time( &mut self, utc_us: u64, granularity: GranularityEnum, source: TimeSourceEnum, change_notifier: &dyn AttrChangeNotifier, ) -> bool
Update the Last-Known-Good UTC Time (Matter Core spec),
capturing a fresh monotonic anchor so subsequent
Self::utc_time reads advance from the supplied value.
Per the spec: the supplied granularity is recorded
stepped-down by one level (with a floor of
MinutesGranularity per spec); the supplied source
is recorded verbatim.
The new value is written to the in-memory state immediately.
Persistence to LKG_UTC_KEY happens separately — the
TimeSync cluster handler invokes this from inside a
kv.access(...) closure and writes through the same handle.
Direct callers that need on-disk durability should call
[Self::persist_lkg_utc] explicitly.
pub fn set_utc_time_persist<S>(
&mut self,
utc_us: u64,
granularity: GranularityEnum,
source: TimeSourceEnum,
persist: &mut Persist<S>,
change_notifier: &dyn AttrChangeNotifier,
) -> Result<(), Error>where
S: KvBlobStoreAccess,
Auto Trait Implementations§
impl Freeze for Rtc
impl RefUnwindSafe for Rtc
impl Send for Rtc
impl Sync for Rtc
impl Unpin for Rtc
impl UnsafeUnpin for Rtc
impl UnwindSafe for Rtc
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> 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