pub struct TimeSyncClient<'a, C> { /* private fields */ }Expand description
Initiator-side TimeSync client. Periodically reads UTCTime from
the configured trusted source and stores it as the device’s new
Last-Known-Good UTC Time (Matter Core spec).
Holds a borrow of the Matter instance for its lifetime; the
run / refresh_once methods take the KV-store handle and the
attribute-change notifier (typically your InteractionModel) by reference
so the same client struct can be re-used across refresh cycles.
Implementations§
Source§impl<'a, C> TimeSyncClient<'a, C>where
C: Crypto,
impl<'a, C> TimeSyncClient<'a, C>where
C: Crypto,
Sourcepub const fn new(matter: &'a Matter<'a>, crypto: C) -> TimeSyncClient<'a, C>
pub const fn new(matter: &'a Matter<'a>, crypto: C) -> TimeSyncClient<'a, C>
Create a new client bound to matter.
crypto is needed because reading the trusted time source may require
establishing a fresh CASE session (via Exchange::initiate) when none
is cached.
Sourcepub async fn run<S, N>(
&self,
period: Duration,
kv: S,
notify: &N,
) -> Result<(), Error>where
S: KvBlobStoreAccess,
N: AttrChangeNotifier,
pub async fn run<S, N>(
&self,
period: Duration,
kv: S,
notify: &N,
) -> Result<(), Error>where
S: KvBlobStoreAccess,
N: AttrChangeNotifier,
Run the periodic refresh loop. Calls
Self::refresh_once every period; logs and continues on
any per-cycle error so a single bad exchange doesn’t take the
task down. Never returns under normal operation.
Sourcepub async fn refresh_once<S, N>(&self, kv: S, notify: &N) -> Result<(), Error>where
S: KvBlobStoreAccess,
N: AttrChangeNotifier,
pub async fn refresh_once<S, N>(&self, kv: S, notify: &N) -> Result<(), Error>where
S: KvBlobStoreAccess,
N: AttrChangeNotifier,
Perform a single refresh cycle.
- If no Trusted Time Source is configured, returns
Ok(())with no action. - Otherwise opens a CASE-secured initiator exchange to the
configured
(fab_idx, node_id), reads theUTCTimeattribute on the configuredendpoint, and on a non-null result calls [Matter::set_utc_time] withGranularity = SecondsGranularityandTimeSource = NodeTimeCluster(per spec — the source that this device used to sync its time was another node’s TimeSync cluster).
Auto Trait Implementations§
impl<'a, C> !RefUnwindSafe for TimeSyncClient<'a, C>
impl<'a, C> !Send for TimeSyncClient<'a, C>
impl<'a, C> !Sync for TimeSyncClient<'a, C>
impl<'a, C> !UnwindSafe for TimeSyncClient<'a, C>
impl<'a, C> Freeze for TimeSyncClient<'a, C>where
C: Freeze,
impl<'a, C> Unpin for TimeSyncClient<'a, C>where
C: Unpin,
impl<'a, C> UnsafeUnpin for TimeSyncClient<'a, C>where
C: UnsafeUnpin,
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