Skip to main content

TimeZoneStore

Struct TimeZoneStore 

Source
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>

Source

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.

Source

pub fn init() -> impl Init<TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>>

Return an in-place initializer for TimeZoneStore.

Source

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.

Source

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.

Source

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.

Source

pub fn generation(&self) -> u32

The current change generation; bumped on every accepted mutation.

Source

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.

Source

pub fn active_dst_offset(&self, now: u64) -> Option<i32>

The DST offset active at now, if any.

Source

pub fn dst_table_empty(&self) -> bool

Whether the DST table is empty.

Source

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.

Source

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>

Source§

fn default() -> TimeZoneStore<TIME_ZONE_MAX, DST_OFFSET_MAX>

Returns the “default value” for a type. Read more
Source§

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>

Stream the active time-zone entries into visit.
Source§

fn dst_offset( &self, visit: &mut dyn FnMut(&DSTOffsetEntry) -> Result<(), Error>, ) -> Result<(), Error>

Stream the active DST-offset entries into visit.
Source§

fn time_zone_database(&self) -> Result<TimeZoneDatabaseEnum, Error>

How complete the device’s IANA time-zone database is.
Source§

fn time_zone_list_max_size(&self) -> Result<u8, Error>

Maximum length of the TimeZone list this device accepts.
Source§

fn dst_offset_list_max_size(&self) -> Result<u8, Error>

Maximum length of the DSTOffset list this device accepts.
Source§

fn set_time_zone(&self, request: &SetTimeZoneRequest<'_>) -> Result<bool, Error>

Handle SetTimeZone. Returns the DSTOffsetRequired field for the response.
Source§

fn set_dst_offset(&self, request: &SetDSTOffsetRequest<'_>) -> Result<(), Error>

Handle 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, E> Init<T, E> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, I> IntoFallibleInit<T> for I
where I: Init<T>,

Source§

fn into_fallible<E>(self) -> impl Init<T, E>

Convert the infallible initializer to a fallible one.
Source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T, E> PinInit<T, E> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V