Expand description
HomeKit accessory attribute database — Milestone 6 of hap-rust.
hap-model is transport-agnostic. It parses the /accessories JSON into
a typed Accessory → Service → Characteristic tree and builds /
parses the /characteristics request and response bodies. It never touches
the network: the controller (hap-controller, M7) executes the requests
this crate produces over a secure session.
§Example
use hap_model::parse_accessories;
let body = br#"{"accessories":[{"aid":1,"services":[
{"iid":1,"type":"3E","characteristics":[
{"iid":2,"type":"23","format":"string","perms":["pr"],"value":"Lamp"}
]}
]}]}"#;
let accessories = parse_accessories(body).unwrap();
assert_eq!(accessories[0].aid, 1);The doc-test uses unwrap(); real library code must propagate the
Result instead.
Re-exports§
pub use database::AccessoryDatabase;pub use database::Request;pub use database::RequestExecutor;pub use error::ModelError;pub use error::Result;pub use format::CharFormat;pub use format::CharValue;pub use perms::Perms;pub use status::HapStatus;pub use tree::Accessory;pub use tree::Characteristic;pub use tree::Service;pub use unit::Unit;pub use uuid::Uuid;
Modules§
- database
- A thin typed-access layer over a caller-supplied request executor.
- error
- Error type for
hap-model. - format
- Characteristic value formats and decoded values.
- perms
- Characteristic permissions.
- status
- HAP per-characteristic status codes.
- tree
- The typed accessory attribute tree:
Accessory→Service→Characteristic. - unit
- HAP characteristic units (the spec
unitfield). - uuid
- HAP type UUIDs.
Structs§
- Char
Read - One decoded entry from a
GET /characteristicsresponse.
Enums§
- Characteristic
Type - HAP-defined CharacteristicType (generated).
Unknowncarries any non-HAP UUID. - Service
Type - HAP-defined ServiceType (generated).
Unknowncarries any non-HAP UUID.
Functions§
- build_
prepare_ request - Build the JSON body for
PUT /prepare: a timed-write reservation. - build_
read_ request - Build the path+query for
GET /characteristics?id=.... - build_
subscribe_ request - Build the JSON body for
PUT /characteristicssubscribing (enable=true) or unsubscribing (enable=false) to events for each(aid,iid). - build_
timed_ write_ request - Build a
PUT /characteristicsbody for a timed write: every entry carries thepidfrom a precedingbuild_prepare_request. - build_
write_ request - Build the JSON body for
PUT /characteristicswriting each(aid,iid)itsCharValue. - build_
write_ request_ with_ response - Build a
PUT /characteristicsbody requesting the post-write value back (the HAPrflag). - parse_
accessories - Parse the body of a
GET /accessoriesresponse into the typed tree. - parse_
read_ response - Parse a
GET /characteristicsresponse body into((aid,iid), CharValue)pairs for the successful entries.