hap_model/lib.rs
1//! HomeKit accessory attribute database — Milestone 6 of `hap-rust`.
2//!
3//! `hap-model` is transport-agnostic. It parses the `/accessories` JSON into
4//! a typed [`Accessory`] → [`Service`] → [`Characteristic`] tree and builds /
5//! parses the `/characteristics` request and response bodies. It never touches
6//! the network: the controller (`hap-controller`, M7) executes the requests
7//! this crate produces over a secure session.
8//!
9//! # Example
10//!
11//! ```
12//! use hap_model::parse_accessories;
13//!
14//! let body = br#"{"accessories":[{"aid":1,"services":[
15//! {"iid":1,"type":"3E","characteristics":[
16//! {"iid":2,"type":"23","format":"string","perms":["pr"],"value":"Lamp"}
17//! ]}
18//! ]}]}"#;
19//! let accessories = parse_accessories(body).unwrap();
20//! assert_eq!(accessories[0].aid, 1);
21//! ```
22//!
23//! The doc-test uses `unwrap()`; real library code must propagate the
24//! [`Result`] instead.
25
26#![forbid(unsafe_code)]
27
28pub mod database;
29pub mod error;
30pub mod format;
31pub mod perms;
32pub mod status;
33pub mod tree;
34pub mod unit;
35pub mod uuid;
36
37mod accessories;
38mod characteristics;
39mod generated;
40
41pub use accessories::parse_accessories;
42pub use characteristics::{
43 build_prepare_request, build_read_request, build_subscribe_request, build_timed_write_request,
44 build_write_request, build_write_request_with_response, parse_read_response, CharRead,
45};
46pub use database::{AccessoryDatabase, Request, RequestExecutor};
47pub use error::{ModelError, Result};
48pub use format::{CharFormat, CharValue};
49pub use generated::{CharacteristicType, ServiceType};
50pub use perms::Perms;
51pub use status::HapStatus;
52pub use tree::{Accessory, Characteristic, Service};
53pub use unit::Unit;
54pub use uuid::Uuid;