pub struct TimeZoneStore<const TIME_ZONE_MAX: usize = 2, const DST_OFFSET_MAX: usize = 2> { /* private fields */ }Expand description
A concrete [TimeSync] provider implementing the TIME_ZONE feature’s
storage and validation: the TimeZone / DSTOffset lists with all the
Matter Core spec constraint checks on SetTimeZone / SetDSTOffset.
Pure validated storage: event emission, persistence and LocalTime
computation are orchestrated by TimeSyncHandler, which has the
contexts this store deliberately does not.
TimeZoneDatabase is reported as None - names are stored and echoed
back verbatim, but never interpreted.
Implementations§
Source§impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
Sourcepub const fn new() -> TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
pub const fn new() -> TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
Create a store with the spec-default single {offset: 0, valid_at: 0}
time-zone entry and no DST offsets.
Sourcepub fn init() -> impl Init<TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>>
pub fn init() -> impl Init<TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>>
Return an in-place initializer for TimeZoneStore.
Sourcepub async fn wait_changed(&self)
pub async fn wait_changed(&self)
Wait until the store’s contents (or the node’s UTC time) may have changed. Used by the transition timer.
Sourcepub fn note_changed(&self)
pub fn note_changed(&self)
Signal Self::wait_changed waiters. Called internally on accepted
mutations; also called by the handler when UTC time is (re)set, since
that changes which entries are active.
Sourcepub fn load_persist<S>(&self, store: S, buf: &mut [u8]) -> Result<(), Error>where
S: KvBlobStore,
pub fn load_persist<S>(&self, store: S, buf: &mut [u8]) -> Result<(), Error>where
S: KvBlobStore,
Re-hydrate both lists from store under TIME_ZONE_KEY. Call at
startup, before the store is shared with the handler. A missing key
(first boot / cleared persistence) leaves the defaults.
Sourcepub fn generation(&self) -> u32
pub fn generation(&self) -> u32
The current change generation; bumped on every accepted mutation.
Sourcepub fn active_time_zone(
&self,
now: u64,
) -> (i32, Option<StringInner<usize, VecStorageInner<[MaybeUninit<u8>; 64]>>>)
pub fn active_time_zone( &self, now: u64, ) -> (i32, Option<StringInner<usize, VecStorageInner<[MaybeUninit<u8>; 64]>>>)
The (offset, name) of the currently-active time-zone entry: the last
entry whose valid_at has passed, or the implicit (0, None) default
when the list is empty.
Sourcepub fn active_dst_offset(&self, now: u64) -> Option<i32>
pub fn active_dst_offset(&self, now: u64) -> Option<i32>
The DST offset active at now, if any.
Sourcepub fn dst_table_empty(&self) -> bool
pub fn dst_table_empty(&self) -> bool
Whether the DST table is empty.
Sourcepub fn dst_usable(&self, now: u64) -> bool
pub fn dst_usable(&self, now: u64) -> bool
Whether the DST table still carries usable information at now: at
least one entry is active or scheduled (its valid_until is Null or in
the future).
false covers both “empty” (e.g. just cleared by SetTimeZone) and
“exhausted” (every entry expired). DSTTableEmpty is emitted on the
usable -> not-usable edge - TC_TIMESYNC_2_10 requires it both when
SetTimeZone clears a non-empty table and when the last entry expires
naturally. Entries are deliberately retained rather than pruned:
TestTimeSynchronization (and chip) expect DSTOffset reads to return
exactly what was written.
Sourcepub fn next_transition(&self, now: u64) -> Option<u64>
pub fn next_transition(&self, now: u64) -> Option<u64>
The next Matter-epoch-microseconds instant after now at which the
active time zone or DST state can change - i.e. the earliest
valid_at / valid_starting / valid_until still in the future.
None when no transition is scheduled.
Trait Implementations§
Source§impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> Default for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> Default for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
Source§fn default() -> TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
fn default() -> TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
Source§impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> TimeZones for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> TimeZones for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
Source§fn time_zone(
&self,
visit: &mut dyn FnMut(&TimeZoneEntry<'_>) -> Result<(), Error>,
) -> Result<(), Error>
fn time_zone( &self, visit: &mut dyn FnMut(&TimeZoneEntry<'_>) -> Result<(), Error>, ) -> Result<(), Error>
visit.Source§fn dst_offset(
&self,
visit: &mut dyn FnMut(&DSTOffsetEntry) -> Result<(), Error>,
) -> Result<(), Error>
fn dst_offset( &self, visit: &mut dyn FnMut(&DSTOffsetEntry) -> Result<(), Error>, ) -> Result<(), Error>
visit.Source§fn time_zone_database(&self) -> Result<TimeZoneDatabaseEnum, Error>
fn time_zone_database(&self) -> Result<TimeZoneDatabaseEnum, Error>
Source§fn time_zone_list_max_size(&self) -> Result<u8, Error>
fn time_zone_list_max_size(&self) -> Result<u8, Error>
TimeZone list this device accepts.Source§fn dst_offset_list_max_size(&self) -> Result<u8, Error>
fn dst_offset_list_max_size(&self) -> Result<u8, Error>
DSTOffset list this device accepts.Source§fn set_time_zone(&self, request: &SetTimeZoneRequest<'_>) -> Result<bool, Error>
fn set_time_zone(&self, request: &SetTimeZoneRequest<'_>) -> Result<bool, Error>
SetTimeZone. Returns the DSTOffsetRequired field for the
response.Source§fn set_dst_offset(&self, request: &SetDSTOffsetRequest<'_>) -> Result<(), Error>
fn set_dst_offset(&self, request: &SetDSTOffsetRequest<'_>) -> Result<(), Error>
SetDSTOffset.Auto Trait Implementations§
impl<const TIME_ZONE_MAX: usize = 2, const DST_OFFSET_MAX: usize = 2> !Freeze for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize = 2, const DST_OFFSET_MAX: usize = 2> !RefUnwindSafe for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize = 2, const DST_OFFSET_MAX: usize = 2> !Sync for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> Send for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> Unpin for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> UnsafeUnpin for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
impl<const TIME_ZONE_MAX: usize, const DST_OFFSET_MAX: usize> UnwindSafe for TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>
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