Expand description
Binding cluster handler (Matter Core spec).
Per-endpoint, fabric-scoped, persistent list of TargetStruct
entries each describing a unicast (node, endpoint, cluster?) or
a groupcast (group, cluster?) destination. The Binding cluster
is the device-side address book a client cluster reads when it
wants to send a command somewhere: a wall switch with OnOff in
its client list, for instance, reads its Binding list to find the
bulb(s) it’s been paired with.
See the spec’s [9.6 summary][spec], or the in-tree write-up in
super::user_label for the analogous (per-endpoint, persistent,
shared-registry) shape.
§Persistence
Spec marks the Binding attribute with the N quality
bit (Non-Volatile, Matter Core) — values SHALL survive
reboots. We re-serialise the whole registry under BINDINGS_KEY
after every successful write, and re-hydrate on startup via
Bindings::load_persist, driven by the LifecycleOp::Startup
lifecycle operation the handler receives (deliver it by calling
InteractionModel::startup once at startup).
§Fabric scoping
TargetStruct carries an implicit FabricIndex field (id 254)
that the IM dispatch auto-injects from the writing accessor. On
reads, attr.fab_filter + attr.fab_idx constrain results to the
reading fabric. We store fab_idx alongside each entry and apply
the same filter manually on read paths.
§Validation
Per spec:
GroupandEndpointare mutually exclusive (one of the two identifies the target).Nodeis required whenEndpointis present.Clusteris optional.
We reject malformed entries with ConstraintError.
Structs§
- Binding
- One binding entry: the local endpoint it is attached to, the fabric it belongs to, and the destination it points at.
- Binding
Attr Reads View - Cluster-scoped view onto an
crate::im::AttrPathArrayBuilderfor theBindingcluster. Each method pushes oneAttrPath(cluster ID baked in) and returnsSelffor chaining;.end()closes the underlying array. Attribute names that would collide with the view’s own inherent methods (seeRESERVED_VIEW_METHOD_NAMESin the codegen) get anattr_prefix. - Binding
Attr Responses View - Cluster-scoped response view onto a
crate::im::ReportDataRespfor theBindingcluster. Each method returns an iterator of(EndptId, Result<T, Error>)over the entries inattr_reportswhose path matches that attribute. Attribute names that would collide with the view’s own inherent methods (seeRESERVED_VIEW_METHOD_NAMESin the codegen) get anattr_prefix. - Binding
Attr Writes View - Cluster-scoped view onto an
crate::im::AttrDataArrayBuilderfor theBindingcluster. Scalar-valued attrs push and returnSelffor 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 (seeRESERVED_VIEW_METHOD_NAMESin the codegen) get anattr_prefix. - Binding
Client View - Per-exchange view onto the
Bindingcluster’s client operations. Returned byBindingClient::binding. Each method consumes the view (and therefore the underlyingcrate::transport::exchange::Exchange) — one exchange is one IM transaction. - Binding
CmdRequests View - Cluster-scoped view onto a
crate::im::CmdDataArrayBuilderfor theBindingcluster. Empty-request commands push and returnSelf; 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 (seeRESERVED_VIEW_METHOD_NAMESin the codegen — currentlyend, which the WebRTC cluster uses) get acmd_prefix. - Binding
CmdResponses View - Cluster-scoped response view onto a
crate::im::InvokeRespfor theBindingcluster. Each method returns an iterator of(EndptId, Result<R, Error>)over the entries ininvoke_responseswhose path matches that command. Command names that would collide with the view’s own inherent methods (seeRESERVED_VIEW_METHOD_NAMESin the codegen) get acmd_prefix. - Binding
Handler - Per-
(endpoint, Binding)-instance handler facade. Holds only aDataver, the endpoint id it serves, and a borrow of the sharedBindingsregistry. All persisted state lives in the registry. - Binding
Write Responses View - Cluster-scoped write-status view onto a
crate::im::WriteRespfor theBindingcluster. Each method returns an iterator of(EndptId, Result<(), Error>)over the entries inwrite_responseswhose path matches that attribute. Attribute names that would collide with the view’s own inherent methods (seeRESERVED_VIEW_METHOD_NAMESin the codegen) get anattr_prefix. - Bindings
- Shared registry of
Bindingentries across every endpoint and fabric. Persisted as a single TLV blob underBINDINGS_KEY. - Handler
Adaptor - The handler adaptor for the cluster-specific handler. This adaptor implements the generic
rs-matterhandler trait. - Handler
Async Adaptor - The handler adaptor for the cluster-specific handler. This adaptor implements the generic
rs-matterhandler trait. - Target
Struct - Target
Struct Array Builder - Target
Struct Builder
Enums§
- Attribute
Id - The attribute IDs for the cluster.
- Command
Id - The command IDs for the cluster.
- Command
Response Id - The command response IDs for the cluster.
- EventId
- The event IDs for the cluster.
- Target
Struct Tag
Constants§
- BINDINGS_
KEY - The key used for storing all Binding entries across every endpoint+fabric pair that hosts the Binding cluster.
- CLUSTER
- Cluster metadata exposed by
BindingHandler. - 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.
Traits§
- Binding
Attr Reads - IM-client extension trait for the
Bindingcluster’s attribute reads.usethis trait to call.binding_read()on ancrate::im::AttrPathArrayBuilder; the returnedBindingAttrReadsViewexposes one method per attribute (cluster-prefix-free)..end()on the view closes the wrapped array. - Binding
Attr Responses - IM-client extension trait for extracting
Binding-cluster attribute reports out of a genericcrate::im::ReportDataResp.usethis trait to call.binding_read_resp()on aReportDataResp; the returnedBindingAttrResponsesViewexposes 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 asUtf8Str<'a>/OctetStr<'a>, the codegen struct wrapperFoo<'a>, orTLVArray<'a, _>respectively. - Binding
Attr Writes - IM-client extension trait for the
Bindingcluster’s attribute writes.usethis trait to call.binding_write()on ancrate::im::AttrDataArrayBuilder; the returnedBindingAttrWritesViewexposes one method per writable attribute (cluster-prefix-free)..end()on the view closes the wrapped array. - Binding
Client - Single-shot IM-client convenience trait for the
Bindingcluster.usethis trait to call.binding()on ancrate::transport::exchange::Exchange; the returnedBindingClientViewexposes 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 returnResult<(), Error>and drain the response internally; response-bearing commands returnResult<<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. - Binding
CmdRequests - IM-client extension trait for the
Bindingcluster’s commands.usethis trait to call.binding_inv()on acrate::im::CmdDataArrayBuilder; the returnedBindingCmdRequestsViewexposes one method per command (cluster-prefix-free)..end()on the view closes the wrapped array. - Binding
CmdResponses - IM-client extension trait for extracting
Binding-cluster command responses out of a genericcrate::im::InvokeResp.usethis trait to call.binding_inv_resp()on anInvokeResp; the returnedBindingCmdResponsesViewexposes one iterator method per command, each yielding(EndptId, Result<<Output>, Error>)— seecrate::im::InvokeResp::responses/crate::im::InvokeResp::statusesfor the per-entry semantics. - Binding
Write Responses - IM-client extension trait for extracting
Binding-cluster per-attribute write statuses out of a genericcrate::im::WriteResp.usethis trait to call.binding_write_resp()on aWriteResp; the returnedBindingWriteResponsesViewexposes one iterator method per writable attribute, each yielding(EndptId, Result<(), Error>). - Cluster
Async Handler - The handler trait for the cluster.
- Cluster
Handler - The handler trait for the cluster.