Skip to main content

Module binding

Module binding 

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

  • Group and Endpoint are mutually exclusive (one of the two identifies the target).
  • Node is required when Endpoint is present.
  • Cluster is 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.
BindingAttrReadsView
Cluster-scoped view onto an crate::im::AttrPathArrayBuilder for the Binding 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.
BindingAttrResponsesView
Cluster-scoped response view onto a crate::im::ReportDataResp for the Binding 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.
BindingAttrWritesView
Cluster-scoped view onto an crate::im::AttrDataArrayBuilder for the Binding 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.
BindingClientView
Per-exchange view onto the Binding cluster’s client operations. Returned by BindingClient::binding. Each method consumes the view (and therefore the underlying crate::transport::exchange::Exchange) — one exchange is one IM transaction.
BindingCmdRequestsView
Cluster-scoped view onto a crate::im::CmdDataArrayBuilder for the Binding 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.
BindingCmdResponsesView
Cluster-scoped response view onto a crate::im::InvokeResp for the Binding 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.
BindingHandler
Per-(endpoint, Binding)-instance handler facade. Holds only a Dataver, the endpoint id it serves, and a borrow of the shared Bindings registry. All persisted state lives in the registry.
BindingWriteResponsesView
Cluster-scoped write-status view onto a crate::im::WriteResp for the Binding 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.
Bindings
Shared registry of Binding entries across every endpoint and fabric. Persisted as a single TLV blob under BINDINGS_KEY.
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.
TargetStruct
TargetStructArrayBuilder
TargetStructBuilder

Enums§

AttributeId
The attribute IDs for the cluster.
CommandId
The command IDs for the cluster.
CommandResponseId
The command response IDs for the cluster.
EventId
The event IDs for the cluster.
TargetStructTag

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§

BindingAttrReads
IM-client extension trait for the Binding cluster’s attribute reads. use this trait to call .binding_read() on an crate::im::AttrPathArrayBuilder; the returned BindingAttrReadsView exposes one method per attribute (cluster-prefix-free). .end() on the view closes the wrapped array.
BindingAttrResponses
IM-client extension trait for extracting Binding-cluster attribute reports out of a generic crate::im::ReportDataResp. use this trait to call .binding_read_resp() on a ReportDataResp; the returned BindingAttrResponsesView 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.
BindingAttrWrites
IM-client extension trait for the Binding cluster’s attribute writes. use this trait to call .binding_write() on an crate::im::AttrDataArrayBuilder; the returned BindingAttrWritesView exposes one method per writable attribute (cluster-prefix-free). .end() on the view closes the wrapped array.
BindingClient
Single-shot IM-client convenience trait for the Binding cluster. use this trait to call .binding() on an crate::transport::exchange::Exchange; the returned BindingClientView 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.
BindingCmdRequests
IM-client extension trait for the Binding cluster’s commands. use this trait to call .binding_inv() on a crate::im::CmdDataArrayBuilder; the returned BindingCmdRequestsView exposes one method per command (cluster-prefix-free). .end() on the view closes the wrapped array.
BindingCmdResponses
IM-client extension trait for extracting Binding-cluster command responses out of a generic crate::im::InvokeResp. use this trait to call .binding_inv_resp() on an InvokeResp; the returned BindingCmdResponsesView 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.
BindingWriteResponses
IM-client extension trait for extracting Binding-cluster per-attribute write statuses out of a generic crate::im::WriteResp. use this trait to call .binding_write_resp() on a WriteResp; the returned BindingWriteResponsesView exposes one iterator method per writable attribute, each yielding (EndptId, Result<(), Error>).
ClusterAsyncHandler
The handler trait for the cluster.
ClusterHandler
The handler trait for the cluster.