pub struct HapBridge {
pub service_record: HapServiceRecord,
/* private fields */
}Expand description
HOMECORE-to-HAP accessory bridge state.
Call HapBridge::add_accessory to register entities and
HapBridge::running_accessories to read back what is currently
registered. Use start_server for the bounded TCP lifecycle.
Fields§
§service_record: HapServiceRecordImplementations§
Source§impl HapBridge
impl HapBridge
Sourcepub fn new(service_record: HapServiceRecord) -> Self
pub fn new(service_record: HapServiceRecord) -> Self
Create a bridge with the given service record and a NullAdvertiser.
Sourcepub fn with_advertiser(
service_record: HapServiceRecord,
advertiser: Arc<dyn MdnsAdvertiser>,
) -> Self
pub fn with_advertiser( service_record: HapServiceRecord, advertiser: Arc<dyn MdnsAdvertiser>, ) -> Self
Create a bridge with a custom MdnsAdvertiser.
Sourcepub fn add_accessory(
&self,
entity_id: &EntityId,
state: &State,
) -> Result<(), HapError>
pub fn add_accessory( &self, entity_id: &EntityId, state: &State, ) -> Result<(), HapError>
Register an entity as a HAP accessory.
The entity’s current mapping is computed from state; call
update_accessory on each StateChanged event to keep it fresh.
Returns HapError::AlreadyRegistered if the entity is already
registered. Call remove_accessory first to replace it.
Sourcepub fn remove_accessory(&self, entity_id: &EntityId) -> Result<(), HapError>
pub fn remove_accessory(&self, entity_id: &EntityId) -> Result<(), HapError>
Remove a registered accessory.
Returns HapError::EntityNotFound if the entity was not registered.
Sourcepub fn update_accessory(
&self,
entity_id: &EntityId,
state: &State,
) -> Result<(), HapError>
pub fn update_accessory( &self, entity_id: &EntityId, state: &State, ) -> Result<(), HapError>
Refresh a registered accessory and notify event subscribers.
Sourcepub fn subscribe_events(&self) -> Receiver<CharacteristicEvent>
pub fn subscribe_events(&self) -> Receiver<CharacteristicEvent>
Subscribe to bounded characteristic updates. Lagging receivers receive
Tokio’s explicit Lagged error and must resynchronize from a snapshot.
Sourcepub fn running_accessories(&self) -> Vec<ExposedAccessory>
pub fn running_accessories(&self) -> Vec<ExposedAccessory>
Snapshot all currently registered accessories.