knx-catalog 0.0.8

Reviewed KNX datapoint-type catalogue as const data
Documentation
//! Reviewed KNX datapoint-type catalogue as const data.
//!
//! The catalogue is the single internal authority for source-derived
//! declarative facts about datapoint types: identifiers, official names,
//! transmitted widths, field decompositions, ranges, resolutions, code
//! tables, named bit layouts, special values, validity associations,
//! cross-field relations, context requirements and group-transport
//! eligibility. Consumers read these facts here instead of interpreting
//! the specification independently.
//!
//! The data under [`generated`] is produced by the `knx-data-gen` tool from
//! reviewed structured input. It is committed, deterministic, and never
//! edited by hand; the reviewed input is the authority over the generated
//! output.
//!
//! The schema types here are open data records - public fields, no
//! constructors - because they state declarations rather than enforce
//! invariants; the validated primitives with sealed fields and checked
//! constructors live in the crates that own behavior.

#![no_std]
#![forbid(unsafe_code)]
#![deny(missing_docs)]
#![deny(clippy::indexing_slicing)]

pub mod generated;
pub mod id;
pub mod schema;

pub use id::{DptId, ParseIdError};
pub use schema::SubtypeRow;

/// Looks up the catalogue row for `id`.
///
/// Returns `None` when the identifier is not catalogued. The catalogue states
/// what the reviewed data records about a datapoint type, not what this build
/// implements; distinguishing an uncatalogued identifier from a
/// catalogued-but-unimplemented one belongs to the registration layer.
pub fn find(id: DptId) -> Option<&'static SubtypeRow> {
    let rows = generated::subtypes::SUBTYPES;
    rows.binary_search_by(|row| row.id.cmp(&id)).ok().and_then(|index| rows.get(index))
}