Skip to main content

Module time_sync

Module time_sync 

Source
Expand description

Implementation of the Time Synchronization cluster.

§Cluster-shape selection — endpoint-side, via Options

Each Matter feature (TIME_ZONE, NTP_CLIENT, NTP_SERVER, TIME_SYNC_CLIENT) is mirrored 1:1 by a bit in the Options bitflags type, consumed by the cluster const-generic fn which returns the matching Cluster<'static> metadata.

The shape is picked endpoint-side, on the clusters! / root_endpoint! macros — e.g. clusters!(eth, time_sync(time_zone, ntp_client); …) — not on the handler. TimeSyncHandler itself is non-generic and its Self::CLUSTER is pinned to the empty-options shape; only CLUSTER.id is actually consulted by the dispatcher, and the per-attribute / per-command dispatch is driven by what the endpoint advertises.

Spec invariant carried over independently of features: TimeSource is opted in even in the empty-options shape so the Matter test harness’s has_attribute(TimeSource) gate on TC_TIMESYNC_2_1 matches and the test runs rather than skipping.

§Pluggable data source — [TimeSync]

The cluster’s mandatory members (UTCTime, Granularity, TimeSource, and the SetUTCTime command) are handled by TimeSyncHandler directly against the Matter-wide Last-Known-Good UTC Time state — they require no implementor input.

[TimeSync] only carries the feature-gated members (TIME_ZONE / NTP_CLIENT / NTP_SERVER / TIME_SYNC_CLIENT). Every method has a “no value” default so impl TimeSync for () is a fully usable no-op provider; implementors only override the methods matching the options they advertised.

Modules§

client
Time Synchronization initiator-side client (Matter Core spec).

Structs§

DSTOffsetEntry
One DST-offset entry yielded by [TimeSync::dst_offset] via the visitor callback.
DSTOffsetStruct
DSTOffsetStructArrayBuilder
DSTOffsetStructBuilder
DSTStatus
DSTStatusArrayBuilder
DSTStatusBuilder
DSTTableEmpty
DSTTableEmptyArrayBuilder
DSTTableEmptyBuilder
FabricScopedTrustedTimeSourceStruct
FabricScopedTrustedTimeSourceStructArrayBuilder
FabricScopedTrustedTimeSourceStructBuilder
Feature
HandlerAdaptor
The handler adaptor for the cluster-specific handler. This adaptor implements the generic rs-matter handler trait.
HandlerAsyncAdaptor
The handler adaptor for the cluster-specific handler. This adaptor implements the generic rs-matter handler trait.
MissingTrustedTimeSource
MissingTrustedTimeSourceArrayBuilder
MissingTrustedTimeSourceBuilder
Options
Cluster-shape selectors for the TimeSyncHandler. Each bit turns on exactly one Matter Feature — there are no independent-optional toggles on this cluster, so the mapping is 1:1.
Rtc
Last-Known-Good UTC Time tracking for the device (Matter Core spec).
SetDSTOffsetRequest
SetDSTOffsetRequestArrayBuilder
SetDSTOffsetRequestBuilder
SetDefaultNTPRequest
SetDefaultNTPRequestArrayBuilder
SetDefaultNTPRequestBuilder
SetTimeZoneRequest
SetTimeZoneRequestArrayBuilder
SetTimeZoneRequestBuilder
SetTimeZoneResponse
SetTimeZoneResponseArrayBuilder
SetTimeZoneResponseBuilder
SetTimeZoneResponseHandle
Single-shot handle wrapping the [InvokeRespChunk] of a SetTimeZoneResponse response. Holds the exchange’s RX buffer alive; response() parses the embedded CommandDataIB into a borrowed SetTimeZoneResponse. The trailing StatusResponse(Success) is sent when the caller .complete().await?s the handle.
SetTrustedTimeSourceRequest
SetTrustedTimeSourceRequestArrayBuilder
SetTrustedTimeSourceRequestBuilder
SetUTCTimeRequest
SetUTCTimeRequestArrayBuilder
SetUTCTimeRequestBuilder
TimeFailure
TimeFailureArrayBuilder
TimeFailureBuilder
TimeSyncHandler
Handler for the Time Synchronization Matter cluster.
TimeSynchronizationAttrReadsView
Cluster-scoped view onto an crate::im::AttrPathArrayBuilder for the TimeSynchronization cluster. Each method pushes one AttrPath (cluster ID baked in) and returns Self for chaining; .end() closes the underlying array. Attribute names that would collide with the view’s own inherent methods (see RESERVED_VIEW_METHOD_NAMES in the codegen) get an attr_ prefix.
TimeSynchronizationAttrResponsesView
Cluster-scoped response view onto a crate::im::ReportDataResp for the TimeSynchronization cluster. Each method returns an iterator of (EndptId, Result<T, Error>) over the entries in attr_reports whose path matches that attribute. Attribute names that would collide with the view’s own inherent methods (see RESERVED_VIEW_METHOD_NAMES in the codegen) get an attr_ prefix.
TimeSynchronizationAttrWritesView
Cluster-scoped view onto an crate::im::AttrDataArrayBuilder for the TimeSynchronization cluster. Scalar-valued attrs push and return Self for chaining; struct/list-valued attrs return the codegen-emitted typed value builder (whose parent chain bypasses the view — close back to the array via Data + AttrData .end()?s). .end() closes the wrapped array. Attribute names that would collide with the view’s own inherent methods (see RESERVED_VIEW_METHOD_NAMES in the codegen) get an attr_ prefix.
TimeSynchronizationClientView
Per-exchange view onto the TimeSynchronization cluster’s client operations. Returned by TimeSynchronizationClient::time_synchronization. Each method consumes the view (and therefore the underlying crate::transport::exchange::Exchange) — one exchange is one IM transaction.
TimeSynchronizationCmdRequestsView
Cluster-scoped view onto a crate::im::CmdDataArrayBuilder for the TimeSynchronization cluster. Empty-request commands push and return Self; parameterized commands return the codegen-emitted typed request builder (whose parent chain bypasses the view — close back to the array via Data + CmdData .end()?s). .end() closes the wrapped array. Command names that would collide with the view’s own inherent methods (see RESERVED_VIEW_METHOD_NAMES in the codegen — currently end, which the WebRTC cluster uses) get a cmd_ prefix.
TimeSynchronizationCmdResponsesView
Cluster-scoped response view onto a crate::im::InvokeResp for the TimeSynchronization cluster. Each method returns an iterator of (EndptId, Result<R, Error>) over the entries in invoke_responses whose path matches that command. Command names that would collide with the view’s own inherent methods (see RESERVED_VIEW_METHOD_NAMES in the codegen) get a cmd_ prefix.
TimeSynchronizationWriteResponsesView
Cluster-scoped write-status view onto a crate::im::WriteResp for the TimeSynchronization cluster. Each method returns an iterator of (EndptId, Result<(), Error>) over the entries in write_responses whose path matches that attribute. Attribute names that would collide with the view’s own inherent methods (see RESERVED_VIEW_METHOD_NAMES in the codegen) get an attr_ prefix.
TimeZoneEntry
One time-zone entry yielded by [TimeSync::time_zone] via the visitor callback. The lifetime 'a is the borrow of the implementor’s internal storage for the duration of the visit, so name can point straight into the implementor’s table without copying.
TimeZoneStatus
TimeZoneStatusArrayBuilder
TimeZoneStatusBuilder
TimeZoneStore
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.
TimeZoneStruct
TimeZoneStructArrayBuilder
TimeZoneStructBuilder
TrustedTimeSource
Persisted Trusted Time Source descriptor (Matter Core spec). Records which fabric configured the source so that fabric removal can clear it and emit MissingTrustedTimeSource.
TrustedTimeSourceData
Snapshot of the device’s currently-configured trusted time source. Returned by [TimeSync::trusted_time_source] wrapped in a Nullable.
TrustedTimeSourceStruct
TrustedTimeSourceStructArrayBuilder
TrustedTimeSourceStructBuilder

Enums§

AttributeId
The attribute IDs for the cluster.
CommandId
The command IDs for the cluster.
CommandResponseId
The command response IDs for the cluster.
DSTOffsetStructTag
DSTStatusTag
DSTTableEmptyTag
EventId
The event IDs for the cluster.
FabricScopedTrustedTimeSourceStructTag
GranularityEnum
MissingTrustedTimeSourceTag
SetDSTOffsetRequestTag
SetDefaultNTPRequestTag
SetTimeZoneRequestTag
SetTimeZoneResponseTag
SetTrustedTimeSourceRequestTag
SetUTCTimeRequestTag
StatusCode
TimeFailureTag
TimeSourceEnum
TimeZoneDatabaseEnum
TimeZoneStatusTag
TimeZoneStructTag
TrustedTimeSourceStructTag
UtcTime
An enum describing the current UTC timestamp the real-time clock is aware of.

Constants§

FULL_CLUSTER
The cluster metadata. By default, all cluster attributes, commands and events are allowed, and the revision is the latest one. Use Cluster::with_* to reconfigure.
TIME_ZONE_NAME_MAX
Maximum byte length of a TimeZoneStruct::name (spec constraint 0..=64).

Traits§

ClusterAsyncHandler
The handler trait for the cluster.
ClusterHandler
The handler trait for the cluster.
NtpClient
Data provider for the NTP_CLIENT feature.
NtpServer
Data provider for the NTP_SERVER feature.
TimeSynchronizationAttrReads
IM-client extension trait for the TimeSynchronization cluster’s attribute reads. use this trait to call .time_synchronization_read() on an crate::im::AttrPathArrayBuilder; the returned TimeSynchronizationAttrReadsView exposes one method per attribute (cluster-prefix-free). .end() on the view closes the wrapped array.
TimeSynchronizationAttrResponses
IM-client extension trait for extracting TimeSynchronization-cluster attribute reports out of a generic crate::im::ReportDataResp. use this trait to call .time_synchronization_read_resp() on a ReportDataResp; the returned TimeSynchronizationAttrResponsesView exposes one iterator method per attribute (scalar, string, struct and list alike), each yielding (EndptId, Result<T, Error>). The item type borrows the response, so string/struct/list attributes come back as Utf8Str<'a>/OctetStr<'a>, the codegen struct wrapper Foo<'a>, or TLVArray<'a, _> respectively.
TimeSynchronizationAttrWrites
IM-client extension trait for the TimeSynchronization cluster’s attribute writes. use this trait to call .time_synchronization_write() on an crate::im::AttrDataArrayBuilder; the returned TimeSynchronizationAttrWritesView exposes one method per writable attribute (cluster-prefix-free). .end() on the view closes the wrapped array.
TimeSynchronizationClient
Single-shot IM-client convenience trait for the TimeSynchronization cluster. use this trait to call .time_synchronization() on an crate::transport::exchange::Exchange; the returned TimeSynchronizationClientView exposes one method per command and per attribute. Scalar attributes get a by-value <attr>_read(endpoint); non-scalar ones (string/octet/struct/list, whose value borrows the response) get <attr>_read_with(endpoint, |v| …), which hands the borrowed value to the closure and returns its owned result. The cluster ID, command/attribute ID, request opcode, retransmit loop, response-chunk iteration, and status-only handling are all baked in. DefaultSuccess commands return Result<(), Error> and drain the response internally; response-bearing commands return Result<<RespStruct>Handle<'a>, Error> — the handle keeps the RX buffer alive so the caller can read the borrowed response via .response()? before .complete().await?ing the exchange.
TimeSynchronizationCmdRequests
IM-client extension trait for the TimeSynchronization cluster’s commands. use this trait to call .time_synchronization_inv() on a crate::im::CmdDataArrayBuilder; the returned TimeSynchronizationCmdRequestsView exposes one method per command (cluster-prefix-free). .end() on the view closes the wrapped array.
TimeSynchronizationCmdResponses
IM-client extension trait for extracting TimeSynchronization-cluster command responses out of a generic crate::im::InvokeResp. use this trait to call .time_synchronization_inv_resp() on an InvokeResp; the returned TimeSynchronizationCmdResponsesView exposes one iterator method per command, each yielding (EndptId, Result<<Output>, Error>) — see crate::im::InvokeResp::responses / crate::im::InvokeResp::statuses for the per-entry semantics.
TimeSynchronizationWriteResponses
IM-client extension trait for extracting TimeSynchronization-cluster per-attribute write statuses out of a generic crate::im::WriteResp. use this trait to call .time_synchronization_write_resp() on a WriteResp; the returned TimeSynchronizationWriteResponsesView exposes one iterator method per writable attribute, each yielding (EndptId, Result<(), Error>).
TimeZones
Pluggable data source for the feature-gated members of the Time Synchronization cluster (TIME_ZONE / NTP_CLIENT / NTP_SERVER).

Functions§

cluster
Compute the Cluster<'static> metadata for a TimeSync handler advertising the features encoded in OPTS (the Options::bits value). See the Options flags for the per-bit detail.