Skip to main content

Crate matter_model

Crate matter_model 

Source
Expand description

§matter-model

The Matter data model as static lookup tables, and conversion between JSON and Matter TLV guided by them.

The tables are generated at build time from the Matter IDL that rs-matter ships (the CSA’s controller-clusters.matter, from which the C++ SDK and rs-matter generate their own cluster code), so nothing here is typed by hand and a newer rs-matter brings newer clusters.

TLV is self-describing, so any value decodes to JSON even without a schema; the schema adds field names to structures and gives the encoder the signedness, string kind and field tags it cannot guess from JSON.

let on_off = matter_model::cluster_by_name("on_off").unwrap();
assert_eq!(on_off.id, 6);
assert_eq!(on_off.attribute_by_name("OnOff").unwrap().id, 0);

Part of matter-bridge, maintained by Pulzar. See the user guide, the library guide and the API documentation.

License: MIT.

Structs§

Attribute
An attribute of a cluster.
BitmapDef
A bitmap.
Cluster
A cluster: its attributes, commands and events.
Command
A command a server accepts.
EnumDef
An enumeration.
Event
An event of a cluster.
Field
A field of a structure, a command or an event.
Shape
What a value is expected to be: its type (if known) and whether it is a list of it.
StructDef
A structure.

Enums§

ConvertError
Why a conversion failed.
Type
The type of a value, as far as JSON conversion needs it.

Constants§

MAX_DEPTH
The deepest nesting either direction accepts. Matter data is a handful of levels deep at most (a list of structures holding a list).

Statics§

CLUSTERS
Every cluster of the IDL, sorted by id.

Functions§

cluster
The cluster with id, if the IDL has it.
cluster_by_name
The cluster named name, compared without case or underscores, so OnOff, onOff and on_off all find the On/Off cluster.
encode_to_vec
Encode a JSON value as one anonymous TLV element, as from_json does, into a new buffer of at most max_len bytes.
from_json
Encode a JSON value as TLV under tag, as shape says it should be.
names_match
Whether two IDL-style names are the same name: ignoring case and _.
snake_case
The snake_case form of an IDL name (OnOff and onOff give on_off), as used in MQTT topics.
to_json
Decode a TLV element to JSON, naming structure fields from shape where it has them.