Skip to main content

knx_catalog/
lib.rs

1//! Reviewed KNX datapoint-type catalogue as const data.
2//!
3//! The catalogue is the single internal authority for source-derived
4//! declarative facts about datapoint types: identifiers, official names,
5//! transmitted widths, field decompositions, ranges, resolutions, code
6//! tables, named bit layouts, special values, validity associations,
7//! cross-field relations, context requirements and group-transport
8//! eligibility. Consumers read these facts here instead of interpreting
9//! the specification independently.
10//!
11//! The data under [`generated`] is produced by the `knx-data-gen` tool from
12//! reviewed structured input. It is committed, deterministic, and never
13//! edited by hand; the reviewed input is the authority over the generated
14//! output.
15//!
16//! The schema types here are open data records - public fields, no
17//! constructors - because they state declarations rather than enforce
18//! invariants; the validated primitives with sealed fields and checked
19//! constructors live in the crates that own behavior.
20
21#![no_std]
22#![forbid(unsafe_code)]
23#![deny(missing_docs)]
24#![deny(clippy::indexing_slicing)]
25
26pub mod generated;
27pub mod id;
28pub mod schema;
29
30pub use id::{DptId, ParseIdError};
31pub use schema::SubtypeRow;
32
33/// Looks up the catalogue row for `id`.
34///
35/// Returns `None` when the identifier is not catalogued. The catalogue states
36/// what the reviewed data records about a datapoint type, not what this build
37/// implements; distinguishing an uncatalogued identifier from a
38/// catalogued-but-unimplemented one belongs to the registration layer.
39pub fn find(id: DptId) -> Option<&'static SubtypeRow> {
40    let rows = generated::subtypes::SUBTYPES;
41    rows.binary_search_by(|row| row.id.cmp(&id)).ok().and_then(|index| rows.get(index))
42}