Repository: ewilken/hap-rs Branch: main Commit: acf45bdb00e2 Files: 431 Total size: 2.4 MB Directory structure: gitextract_ilaxg926/ ├── .github/ │ └── workflows/ │ └── ci.yml ├── .gitignore ├── Cargo.toml ├── LICENSE-APACHE ├── LICENSE-MIT ├── README.md ├── codegen/ │ ├── Cargo.toml │ ├── gen/ │ │ ├── README.md │ │ └── system.json │ └── src/ │ └── main.rs ├── examples/ │ ├── adding_accessories_dynamically.rs │ ├── air_purifier.rs │ ├── air_quality_sensor.rs │ ├── async_callbacks.rs │ ├── bridged_accessories.rs │ ├── callbacks.rs │ ├── carbon_dioxide_sensor.rs │ ├── carbon_monoxide_sensor.rs │ ├── contact_sensor.rs │ ├── cooler.rs │ ├── custom_characteristics_services_accessories.rs │ ├── custom_multi_sensor.rs │ ├── dehumidifier.rs │ ├── door.rs │ ├── fan.rs │ ├── fan_v2.rs │ ├── faucet.rs │ ├── garage_door_opener.rs │ ├── heater.rs │ ├── humidifier.rs │ ├── humidity_sensor.rs │ ├── irrigation_system.rs │ ├── leak_sensor.rs │ ├── light_sensor.rs │ ├── lightbulb.rs │ ├── lock.rs │ ├── motion_sensor.rs │ ├── occupancy_sensor.rs │ ├── outlet.rs │ ├── security_system.rs │ ├── setting_values_after_server_start.rs │ ├── shower_head.rs │ ├── smart_speaker.rs │ ├── smoke_sensor.rs │ ├── stateful_programmable_switch.rs │ ├── stateless_programmable_switch.rs │ ├── storing_arbitrary_bytes.rs │ ├── switch.rs │ ├── television.rs │ ├── temperature_sensor.rs │ ├── thermostat.rs │ ├── wi_fi_router.rs │ ├── wi_fi_satellite.rs │ ├── window.rs │ └── window_covering.rs ├── rls.toml ├── rustfmt.toml └── src/ ├── accessory/ │ ├── category.rs │ ├── defined/ │ │ ├── bridge.rs │ │ ├── faucet.rs │ │ ├── heater_cooler.rs │ │ ├── irrigation_system.rs │ │ ├── lightbulb.rs │ │ ├── lock.rs │ │ ├── mod.rs │ │ ├── shower_head.rs │ │ └── television.rs │ ├── generated/ │ │ ├── air_purifier.rs │ │ ├── air_quality_sensor.rs │ │ ├── carbon_dioxide_sensor.rs │ │ ├── carbon_monoxide_sensor.rs │ │ ├── contact_sensor.rs │ │ ├── door.rs │ │ ├── fan.rs │ │ ├── fan_v2.rs │ │ ├── garage_door_opener.rs │ │ ├── humidifier_dehumidifier.rs │ │ ├── humidity_sensor.rs │ │ ├── leak_sensor.rs │ │ ├── light_sensor.rs │ │ ├── mod.rs │ │ ├── motion_sensor.rs │ │ ├── occupancy_sensor.rs │ │ ├── outlet.rs │ │ ├── security_system.rs │ │ ├── smart_speaker.rs │ │ ├── smoke_sensor.rs │ │ ├── stateful_programmable_switch.rs │ │ ├── stateless_programmable_switch.rs │ │ ├── switch.rs │ │ ├── temperature_sensor.rs │ │ ├── thermostat.rs │ │ ├── wi_fi_router.rs │ │ ├── wi_fi_satellite.rs │ │ ├── window.rs │ │ └── window_covering.rs │ └── mod.rs ├── characteristic/ │ ├── generated/ │ │ ├── access_code_control_point.rs │ │ ├── access_code_supported_configuration.rs │ │ ├── access_control_level.rs │ │ ├── accessory_flags.rs │ │ ├── accessory_identifier.rs │ │ ├── active.rs │ │ ├── active_identifier.rs │ │ ├── activity_interval.rs │ │ ├── administrator_only_access.rs │ │ ├── air_particulate_density.rs │ │ ├── air_particulate_size.rs │ │ ├── airplay_enable.rs │ │ ├── application_matching_identifier.rs │ │ ├── asset_update_readiness.rs │ │ ├── audio_feedback.rs │ │ ├── battery_level.rs │ │ ├── brightness.rs │ │ ├── button_event.rs │ │ ├── camera_operating_mode_indicator.rs │ │ ├── carbon_dioxide_detected.rs │ │ ├── carbon_dioxide_level.rs │ │ ├── carbon_dioxide_peak_level.rs │ │ ├── carbon_monoxide_detected.rs │ │ ├── carbon_monoxide_level.rs │ │ ├── carbon_monoxide_peak_level.rs │ │ ├── cca_energy_detect_threshold.rs │ │ ├── cca_signal_detect_threshold.rs │ │ ├── characteristic_value_active_transition_count.rs │ │ ├── characteristic_value_transition_control.rs │ │ ├── charging_state.rs │ │ ├── closed_captions.rs │ │ ├── cloud_relay_control_point.rs │ │ ├── cloud_relay_current_state.rs │ │ ├── cloud_relay_enable_status.rs │ │ ├── color_temperature.rs │ │ ├── configuration_state.rs │ │ ├── configured_name.rs │ │ ├── contact_sensor_state.rs │ │ ├── cooling_threshold_temperature.rs │ │ ├── current_air_purifier_state.rs │ │ ├── current_air_quality.rs │ │ ├── current_door_state.rs │ │ ├── current_fan_state.rs │ │ ├── current_heater_cooler_state.rs │ │ ├── current_heating_cooling_state.rs │ │ ├── current_horizontal_tilt_angle.rs │ │ ├── current_humidifier_dehumidifier_state.rs │ │ ├── current_light_level.rs │ │ ├── current_media_state.rs │ │ ├── current_position.rs │ │ ├── current_relative_humidity.rs │ │ ├── current_slat_state.rs │ │ ├── current_temperature.rs │ │ ├── current_tilt_angle.rs │ │ ├── current_transport.rs │ │ ├── current_vertical_tilt_angle.rs │ │ ├── current_visibility_state.rs │ │ ├── current_water_level.rs │ │ ├── data_stream_hap_transport.rs │ │ ├── data_stream_hap_transport_interrupt.rs │ │ ├── digital_zoom.rs │ │ ├── display_order.rs │ │ ├── event_retransmission_maximum.rs │ │ ├── event_snapshots_active.rs │ │ ├── event_transmission_counters.rs │ │ ├── filter_change_indication.rs │ │ ├── filter_life_level.rs │ │ ├── filter_reset_change_indication.rs │ │ ├── firmware_revision.rs │ │ ├── firmware_update_readiness.rs │ │ ├── firmware_update_status.rs │ │ ├── hardware_finish.rs │ │ ├── hardware_revision.rs │ │ ├── heart_beat.rs │ │ ├── heating_threshold_temperature.rs │ │ ├── hold_position.rs │ │ ├── homekit_camera_active.rs │ │ ├── hue.rs │ │ ├── identifier.rs │ │ ├── identify.rs │ │ ├── image_mirroring.rs │ │ ├── image_rotation.rs │ │ ├── in_use.rs │ │ ├── input_device_type.rs │ │ ├── input_source_type.rs │ │ ├── is_configured.rs │ │ ├── label_index.rs │ │ ├── label_namespace.rs │ │ ├── leak_detected.rs │ │ ├── list_pairings.rs │ │ ├── lock_control_point.rs │ │ ├── lock_current_state.rs │ │ ├── lock_last_known_action.rs │ │ ├── lock_management_auto_security_timeout.rs │ │ ├── lock_physical_controls.rs │ │ ├── lock_target_state.rs │ │ ├── logs.rs │ │ ├── mac_retransmission_maximum.rs │ │ ├── mac_transmission_counters.rs │ │ ├── managed_network_enable.rs │ │ ├── manually_disabled.rs │ │ ├── manufacturer.rs │ │ ├── maximum_transmit_power.rs │ │ ├── mod.rs │ │ ├── model.rs │ │ ├── motion_detected.rs │ │ ├── multifunction_button.rs │ │ ├── mute.rs │ │ ├── name.rs │ │ ├── network_access_violation_control.rs │ │ ├── network_client_control.rs │ │ ├── network_client_status_control.rs │ │ ├── nfc_access_control_point.rs │ │ ├── nfc_access_supported_configuration.rs │ │ ├── night_vision.rs │ │ ├── nitrogen_dioxide_density.rs │ │ ├── obstruction_detected.rs │ │ ├── occupancy_detected.rs │ │ ├── operating_state_response.rs │ │ ├── optical_zoom.rs │ │ ├── outlet_in_use.rs │ │ ├── ozone_density.rs │ │ ├── pair_setup.rs │ │ ├── pair_verify.rs │ │ ├── pairing_features.rs │ │ ├── password_setting.rs │ │ ├── periodic_snapshots_active.rs │ │ ├── picture_mode.rs │ │ ├── ping.rs │ │ ├── pm10_density.rs │ │ ├── pm2_5_density.rs │ │ ├── position_state.rs │ │ ├── power_mode_selection.rs │ │ ├── power_state.rs │ │ ├── product_data.rs │ │ ├── program_mode.rs │ │ ├── programmable_switch_event.rs │ │ ├── programmable_switch_output_state.rs │ │ ├── received_signal_strength_indication.rs │ │ ├── receiver_sensitivity.rs │ │ ├── recording_audio_active.rs │ │ ├── relative_humidity_dehumidifier_threshold.rs │ │ ├── relative_humidity_humidifier_threshold.rs │ │ ├── remaining_duration.rs │ │ ├── remote_key.rs │ │ ├── rotation_direction.rs │ │ ├── rotation_speed.rs │ │ ├── router_status.rs │ │ ├── saturation.rs │ │ ├── security_system_alarm_type.rs │ │ ├── security_system_current_state.rs │ │ ├── security_system_target_state.rs │ │ ├── selected_audio_stream_configuration.rs │ │ ├── selected_camera_recording_configuration.rs │ │ ├── selected_diagnostics_modes.rs │ │ ├── selected_stream_configuration.rs │ │ ├── serial_number.rs │ │ ├── service_signature.rs │ │ ├── set_duration.rs │ │ ├── setup_data_stream_transport.rs │ │ ├── setup_endpoint.rs │ │ ├── setup_transfer_transport.rs │ │ ├── signal_to_noise_ratio.rs │ │ ├── siri_enable.rs │ │ ├── siri_endpoint_session_status.rs │ │ ├── siri_engine_version.rs │ │ ├── siri_input_type.rs │ │ ├── siri_light_on_use.rs │ │ ├── siri_listening.rs │ │ ├── siri_touch_to_use.rs │ │ ├── slat_type.rs │ │ ├── sleep_discovery_mode.rs │ │ ├── sleep_interval.rs │ │ ├── smoke_detected.rs │ │ ├── software_revision.rs │ │ ├── staged_firmware_version.rs │ │ ├── status_active.rs │ │ ├── status_fault.rs │ │ ├── status_jammed.rs │ │ ├── status_low_battery.rs │ │ ├── status_tampered.rs │ │ ├── streaming_status.rs │ │ ├── sulphur_dioxide_density.rs │ │ ├── supported_asset_types.rs │ │ ├── supported_audio_recording_configuration.rs │ │ ├── supported_audio_stream_configuration.rs │ │ ├── supported_camera_recording_configuration.rs │ │ ├── supported_characteristic_value_transition_configuration.rs │ │ ├── supported_data_stream_transport_configuration.rs │ │ ├── supported_diagnostics_modes.rs │ │ ├── supported_diagnostics_snapshot.rs │ │ ├── supported_firmware_update_configuration.rs │ │ ├── supported_router_configuration.rs │ │ ├── supported_rtp_configuration.rs │ │ ├── supported_target_configuration.rs │ │ ├── supported_transfer_transport_configuration.rs │ │ ├── supported_video_recording_configuration.rs │ │ ├── supported_video_stream_configuration.rs │ │ ├── swing_mode.rs │ │ ├── target_air_purifier_state.rs │ │ ├── target_door_state.rs │ │ ├── target_fan_state.rs │ │ ├── target_heater_cooler_state.rs │ │ ├── target_heating_cooling_state.rs │ │ ├── target_horizontal_tilt_angle.rs │ │ ├── target_humidifier_dehumidifier_state.rs │ │ ├── target_list_configuration.rs │ │ ├── target_media_state.rs │ │ ├── target_position.rs │ │ ├── target_relative_humidity.rs │ │ ├── target_temperature.rs │ │ ├── target_tilt_angle.rs │ │ ├── target_vertical_tilt_angle.rs │ │ ├── target_visibility_state.rs │ │ ├── temperature_display_units.rs │ │ ├── third_party_camera_active.rs │ │ ├── thread_control_point.rs │ │ ├── thread_node_capabilities.rs │ │ ├── thread_openthread_version.rs │ │ ├── thread_status.rs │ │ ├── transmit_power.rs │ │ ├── valve_type.rs │ │ ├── version.rs │ │ ├── video_analysis_active.rs │ │ ├── volatile_organic_compound_density.rs │ │ ├── volume.rs │ │ ├── volume_control_type.rs │ │ ├── volume_selector.rs │ │ ├── wake_configuration.rs │ │ ├── wan_configuration_list.rs │ │ ├── wan_status_list.rs │ │ ├── wi_fi_capabilities.rs │ │ ├── wi_fi_configuration_control.rs │ │ └── wi_fi_satellite_status.rs │ └── mod.rs ├── config.rs ├── error.rs ├── event.rs ├── hap_type.rs ├── lib.rs ├── pairing.rs ├── pin.rs ├── pointer.rs ├── server/ │ ├── ip.rs │ └── mod.rs ├── service/ │ ├── generated/ │ │ ├── access_code.rs │ │ ├── access_control.rs │ │ ├── accessory_information.rs │ │ ├── accessory_metrics.rs │ │ ├── accessory_runtime_information.rs │ │ ├── air_purifier.rs │ │ ├── air_quality_sensor.rs │ │ ├── asset_update.rs │ │ ├── assistant.rs │ │ ├── audio_stream_management.rs │ │ ├── battery.rs │ │ ├── camera_operating_mode.rs │ │ ├── camera_recording_management.rs │ │ ├── camera_stream_management.rs │ │ ├── carbon_dioxide_sensor.rs │ │ ├── carbon_monoxide_sensor.rs │ │ ├── cloud_relay.rs │ │ ├── contact_sensor.rs │ │ ├── data_stream_transport_management.rs │ │ ├── diagnostics.rs │ │ ├── door.rs │ │ ├── doorbell.rs │ │ ├── fan.rs │ │ ├── fan_v2.rs │ │ ├── faucet.rs │ │ ├── filter_maintenance.rs │ │ ├── garage_door_opener.rs │ │ ├── heater_cooler.rs │ │ ├── humidifier_dehumidifier.rs │ │ ├── humidity_sensor.rs │ │ ├── input_source.rs │ │ ├── irrigation_system.rs │ │ ├── label.rs │ │ ├── leak_sensor.rs │ │ ├── light_sensor.rs │ │ ├── lightbulb.rs │ │ ├── lock_management.rs │ │ ├── lock_mechanism.rs │ │ ├── microphone.rs │ │ ├── mod.rs │ │ ├── motion_sensor.rs │ │ ├── nfc_access_service.rs │ │ ├── occupancy_sensor.rs │ │ ├── outlet.rs │ │ ├── pairing.rs │ │ ├── power_management.rs │ │ ├── protocol_information.rs │ │ ├── security_system.rs │ │ ├── siri.rs │ │ ├── siri_endpoint.rs │ │ ├── slats.rs │ │ ├── smart_speaker.rs │ │ ├── smoke_sensor.rs │ │ ├── speaker.rs │ │ ├── stateful_programmable_switch.rs │ │ ├── stateless_programmable_switch.rs │ │ ├── switch.rs │ │ ├── target_control.rs │ │ ├── target_control_management.rs │ │ ├── television.rs │ │ ├── temperature_sensor.rs │ │ ├── thermostat.rs │ │ ├── thread_transport.rs │ │ ├── transfer_transport_management.rs │ │ ├── valve.rs │ │ ├── wi_fi_router.rs │ │ ├── wi_fi_satellite.rs │ │ ├── wi_fi_transport.rs │ │ ├── window.rs │ │ └── window_covering.rs │ └── mod.rs ├── storage/ │ ├── accessory_database.rs │ ├── file_storage.rs │ ├── mod.rs │ └── storage.rs ├── tlv.rs └── transport/ ├── bonjour.rs ├── http/ │ ├── handler/ │ │ ├── accessories.rs │ │ ├── characteristics.rs │ │ ├── identify.rs │ │ ├── mod.rs │ │ ├── pair_setup.rs │ │ ├── pair_verify.rs │ │ └── pairings.rs │ ├── mod.rs │ └── server.rs ├── mdns.rs ├── mod.rs └── tcp.rs ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/ci.yml ================================================ name: CI on: pull_request: push: branches: - main env: RUST_BACKTRACE: 1 jobs: style: name: Check style runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 - name: Install Rust uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: nightly override: true components: rustfmt - name: cargo fmt --check uses: actions-rs/cargo@v1 with: command: fmt args: --all -- --check test: name: Test ${{ matrix.rust }} on ${{ matrix.os }} needs: [style] strategy: matrix: rust: - stable - beta - nightly os: - ubuntu-latest - windows-latest - macOS-latest include: - rust: stable features: '' - rust: beta features: '' - rust: nightly features: '' benches: true runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v1 - name: Install Rust (${{ matrix.rust }}) uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: ${{ matrix.rust }} override: true - name: Build only if: matrix.build-only uses: actions-rs/cargo@v1 with: command: build args: ${{ matrix.features }} - name: Test if: matrix.build-only != true uses: actions-rs/cargo@v1 with: command: test args: ${{ matrix.features }} - name: Test all benches if: matrix.benches && matrix.build-only != true uses: actions-rs/cargo@v1 with: command: test args: --benches ${{ matrix.features }} doc: name: Build docs needs: [style, test] runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v1 - name: Install Rust uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable override: true - name: cargo rustdoc -- -D rustdoc::broken_intra_doc_links uses: actions-rs/cargo@v1 with: command: rustdoc args: -- -D rustdoc::broken_intra_doc_links ================================================ FILE: .gitignore ================================================ Cargo.lock target data .DS_Store ================================================ FILE: Cargo.toml ================================================ [package] name = "hap" version = "0.1.0-pre.15" authors = ["Elias Wilken "] edition = "2021" description = "Rust implementation of the Apple HomeKit Accessory Protocol (HAP)" documentation = "https://docs.rs/hap" readme = "README.md" repository = "https://github.com/ewilken/hap-rs" license = "MIT/Apache-2.0" keywords = ["apple", "homekit"] exclude = [ ".github", ".gitignore", "examples", "LICENSE-APACHE", "LICENSE-MIT", "README.md", "rls.toml", "rustfmt.toml", ] [dependencies] aead = "0.4" async-trait = "0.1" byteorder = "1.3" bytes = "1.0" chacha20poly1305 = "0.8" ed25519-dalek = { version = "1.0", features = ["std", "serde"] } erased-serde = "0.3" macaddr = { version = "1.0.1", features = ["serde"] } futures = "0.3" get_if_addrs = "0.5" hkdf = "0.11" hyper = { version = "0.14", features = ["server", "http1"] } libmdns = "0.6" log = "0.4" num = "0.2" rand = "0.7" serde = { version = "1.0", features = ["rc", "derive"] } serde_json = "1.0" sha2 = "0.9" signature = "1.1" srp = "0.5" thiserror = "1.0" tokio = "1.8" url = "2.1" uuid = { version = "0.8", features = ["v4", "serde"] } x25519-dalek = "0.6" [build-dependencies] handlebars = "2.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" uuid = { version = "0.8", features = ["v4", "serde"] } [dev-dependencies] env_logger = "0.8" serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.8", features = ["rt-multi-thread", "time", "macros"] } [workspace] members = ["codegen"] ================================================ FILE: LICENSE-APACHE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: LICENSE-MIT ================================================ Copyright (c) 2021 Elias Wilken Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # HAP (HomeKit Accessory Protocol) [![CI](https://github.com/ewilken/hap-rs/workflows/CI/badge.svg)](https://github.com/ewilken/hap-rs/actions?query=workflow%3ACI) [![crates.io](https://img.shields.io/crates/v/hap.svg)](https://crates.io/crates/hap) [![docs.rs](https://docs.rs/hap/badge.svg)](https://docs.rs/hap) [![license: MIT/Apache-2.0](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](https://github.com/ewilken/hap-rs) Rust implementation of the Apple HomeKit Accessory Protocol (HAP). This crate supports all HomeKit services and characteristics currently implemented by Apple (on stable macOS versions) and provides the ability to create custom characteristics, services and accessories. The HomeKit Accessory Protocol supports transports over IP and Bluetooth LE. Currently only the transport over IP is implemented in this crate. Accessories are exposed by the implemented HAP Accessory HTTP server and announced via built-in mDNS. ## HomeKit Data Model The HAP defines HomeKit enabled devices as virtual `accessories` that are composed of `services` that are composed of `characteristics`. Characteristics hold values of various data types as well as optional metadata like max/min values or units. Services group characteristics and represent features of the accessory. Every accessory consists of at least one `accessory information service` and any number of additional services. For example a custom ceiling fan accessory may consist of an `accessory information service`, a `fan service` and a `lightbulb service`. ``` Ceiling Fan Accessory | |-- Accessory Information Service | |-- Identify Characteristic | |-- Manufacturer Characteristic | |-- Model Characteristic | |-- Name Characteristic | |-- Serial Characteristic | |-- Fan Service | |-- Power State Characteristic | |-- Rotation Direction Characteristic | |-- Rotation Speed Characteristic | |-- Lightbulb Service | |-- Power State Characteristic | |-- Brightness Characteristic | |-- Hue Characteristic | |-- Saturation Characteristic ``` This crate provides a pre-built accessory for every service predefined by Apple in the HomeKit Accessory Simulator as well as others like Television. Custom characteristics and services can be created, assembled and used alongside the predefined ones. For a full list of the predefined characteristics, services and accessories, see the [docs](https://docs.rs/hap/) or [Apple's official specification](https://developer.apple.com/homekit/). ## Usage Examples ### Creating a simple lightbulb accessory and starting the IP server ```rust use tokio; use hap::{ accessory::{lightbulb::LightbulbAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let lightbulb = LightbulbAccessory::new(1, AccessoryInformation { name: "Acme Lightbulb".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Lightbulb".into(), device_id: MacAddress::new([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Lightbulb, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(lightbulb).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ``` ### Setting sync callbacks to react to remote value reads and updates ```rust use hap::characteristic::CharacteristicCallbacks; lightbulb.lightbulb.power_state.on_read(Some(|| { println!("power_state characteristic read"); Ok(None) })); lightbulb.lightbulb.power_state.on_update(Some(|current_val: &bool, new_val: &bool| { println!("power_state characteristic updated from {} to {}", current_val, new_val); Ok(()) })); ``` ### Setting async callbacks to react to remote value reads and updates ```rust use hap::characteristic::AsyncCharacteristicCallbacks; lightbulb.lightbulb.power_state.on_read_async(Some(|| { async { println!("power_state characteristic read (async)"); Ok(None) } .boxed() })); lightbulb.lightbulb.power_state.on_update_async(Some(|current_val: bool, new_val: bool| { async move { println!("power_state characteristic updated from {} to {} (async)", current_val, new_val); Ok(()) } .boxed() })); ``` ### Setting a characteristic value directly ```rust use hap::{ characteristic::HapCharacteristic, serde_json::Value, }; lightbulb.lightbulb.power_state.set_value(Value::Bool(true)).await.unwrap(); ``` ### Interacting with accessories added to the server `Server::add_accessory` returns a pointer to the accessory that can be used like this: ```rust async { let accessory_ptr = server.add_accessory(accessory).await.unwrap(); } ``` Accessories behind the pointer are represented by the `HapAccessory` trait. The `HapAccessory::get_service` and `HapAccessory::get_mut_service` methods provide access to the services of the accessory, represented by the `HapService` trait. The `HapService::get_characteristic` and `HapService::get_mut_characteristic` methods provide access to the characteristics of the service, represented by the `HapCharacteristic` trait. All services and characteristics are identified by their `HapType`. Accessing and changing the `power_state` characteristic of the `lightbulb` service of a `lightbulb` accessory would look like this: ```rust use hap::{HapType, serde_json::Value}; async { let mut lightbulb_accessory = lightbulb_ptr.lock().await; let lightbulb_service = lightbulb_accessory.get_mut_service(HapType::Lightbulb).unwrap(); let power_state_characteristic = lightbulb_service.get_mut_characteristic(HapType::PowerState).unwrap(); power_state_characteristic.set_value(Value::Bool(true)).await.unwrap(); } ``` A full working example can be found [here](https://github.com/ewilken/hap-rs/blob/master/examples/setting_values_after_server_start.rs). ### (Re-)Determining the IP to bind on IP and port to serve on are set via the `host` and `port` fields of the `Config` struct. On config creation, if not explicitly set, the port defaults to `32000` and the IP is set to that of the first non-loopback network interface detected on the host. After config creation however, that IP isn't implicitly re-evaluated. To do so, an implementor has to explicitly call the `redetermine_local_ip()` method of the `Config` struct. An example of doing that on every program restart while reloading a saved config: ```rust let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); // on config reload, the IP has to be explicitly redetermined let mut storage = FileStorage::current_dir().await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Outlet".into(), device_id: MacAddress::new([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Outlet, ..Default::default() // on config creation, the IP can be implicitly determined }; let mut storage = FileStorage::current_dir().await?; config }, }; ``` ## Development Codegen is handled by the `codegen` crate in the workspace. Generated files are checked in. To run the code generation, do: cargo run --package hap-codegen cargo +nightly fmt ## License HAP is licensed under either of - Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) - MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. ================================================ FILE: codegen/Cargo.toml ================================================ [package] name = "hap-codegen" version = "0.1.0-pre.15" authors = ["Elias Wilken "] edition = "2021" description = "Rust implementation of the Apple HomeKit Accessory Protocol (HAP)" documentation = "https://docs.rs/hap" readme = "README.md" repository = "https://github.com/ewilken/hap-rs" license = "MIT/Apache-2.0" keywords = ["apple", "homekit"] publish = false [dependencies] handlebars = "2.0" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" uuid = { version = "0.8", features = ["v4", "serde"] } ================================================ FILE: codegen/gen/README.md ================================================ ### Getting system definitions cp /System/Library/PrivateFrameworks/HomeKitDaemon.framework/Resources/plain-metadata.config system.json # remove `LegacyCloud` & `LegacyIDS` entries plutil -convert json system.json ================================================ FILE: codegen/gen/system.json ================================================ { "Version": 880, "PlistDictionary": { "HomeKit": { "Notification": { "CoalesceNotifications": { "tilt.current": ["slats"], "brightness": ["lightbulb"], "horizontal-tilt.current": ["window-covering"], "saturation": ["lightbulb"], "position.current": ["window-covering"], "vertical-tilt.current": ["window-covering"], "color-temperature": ["lightbulb"], "hue": ["lightbulb"], "temperature.current": ["sensor.temperature"] }, "NotificationAutoEnabled": { "display-order": ["television"], "position.target": ["door", "window"], "operating-state-response": ["doorbell"], "active": ["access-code"], "lock-mechanism.current-state": ["garage-door-opener", "lock-mechanism"], "security-system-state.current": ["security-system"], "is-configured": ["valve"], "input-event": ["doorbell"], "heart-beat": ["accessory-runtime-information"], "position.hold": ["door", "window"], "configured-name": ["input-source", "television", "smart-speaker"], "lock-mechanism.target-state": ["garage-door-opener", "lock-mechanism"], "position.current": ["door", "window"], "position.state": ["door", "window"], "door-state.current": ["garage-door-opener"], "security-system-state.target": ["security-system"], "door-state.target": ["garage-door-opener"] }, "BulletinBoardEnabled": { "position.hold": ["door", "window"], "lock-mechanism.current-state": ["garage-door-opener", "lock-mechanism"], "position.state": ["door", "window"], "input-event": ["doorbell"], "security-system-state.current": ["security-system"], "door-state.current": ["garage-door-opener"], "position.current": ["door", "window"] } }, "WakeOnOperationsFilter": { "active": { "television": { "Operations": ["Write"], "Values": [1] } } }, "Categories": { "faucet": { "Identifier": 29, "DefaultDescription": "Faucet", "UUID": "43CE6F7E-F7E8-44B4-80CE-5786F6E6CD47" }, "television-set-top-box": { "Identifier": 35, "DefaultDescription": "Television Set Top Box", "UUID": "FB953A08-6CDD-44E0-B011-CFAC559A3CFB" }, "other": { "Identifier": 1, "DefaultDescription": "Other", "UUID": "0FBA259B-05AC-46F2-875F-204ABB6D9FE7" }, "air-heater": { "Identifier": 20, "DefaultDescription": "Air Heater", "UUID": "BF7036FD-93CF-49B5-954F-CD2B760D11DA" }, "window": { "Identifier": 13, "DefaultDescription": "Window", "UUID": "1C501511-408E-4C1E-816B-3FC011FFD5B1" }, "audio-receiver": { "Identifier": 34, "DefaultDescription": "Audio Receiver", "UUID": "BE15659C-3CE6-4FD0-B152-BCDB488446C6" }, "air-purifier": { "Identifier": 19, "DefaultDescription": "Air Purifier", "UUID": "5510B997-D711-4636-870F-82BB61092B15" }, "television": { "Identifier": 31, "DefaultDescription": "Television", "UUID": "830C0952-7CD8-44FB-B0C0-DA4EDB0F32A9" }, "outlet": { "Identifier": 7, "DefaultDescription": "Outlet", "UUID": "730F40D4-6D0E-4903-B09E-520A08AFB78C" }, "garage-door-opener": { "Identifier": 4, "DefaultDescription": "Garage Door Opener", "UUID": "604B6E52-2C87-4596-B4C9-D15077C0C07F" }, "apple-tv": { "Identifier": 24, "DefaultDescription": "Apple TV", "UUID": "F6D2A2AC-3A6E-4E6F-8196-678ABE909D8E" }, "airport": { "Identifier": 27, "DefaultDescription": "AirPort", "UUID": "8BFB739C-1E09-4F7B-ABB8-DD7BADD0E8A9" }, "lightbulb": { "Identifier": 5, "DefaultDescription": "Lightbulb", "UUID": "57D56F4D-3302-41F7-AB34-5365AA180E81" }, "air-humidifier": { "Identifier": 22, "DefaultDescription": "Air Humidifier", "UUID": "3FEB9075-C9AF-4629-ADBC-A853259C645A" }, "window-covering": { "Identifier": 14, "DefaultDescription": "Window Covering", "UUID": "2FB9EE1F-1C21-4D0B-9383-9B65F64DBF0E" }, "shower-head": { "Identifier": 30, "DefaultDescription": "Shower Head", "UUID": "39D2A5B4-F9A6-43F6-90E7-0019F0C0E99F" }, "video-doorbell": { "Identifier": 18, "DefaultDescription": "Video Doorbell", "UUID": "957A52E0-BE03-490C-8305-7B20C1CC17BA" }, "air-conditioner": { "Identifier": 21, "DefaultDescription": "Air Conditioner", "UUID": "18DDD63A-27F9-4341-B59B-759D3D114586" }, "fan": { "Identifier": 3, "DefaultDescription": "Fan", "UUID": "151CB559-0DF9-40AA-8A67-12AF06C4449D" }, "sprinkler": { "Identifier": 28, "DefaultDescription": "Sprinkler", "UUID": "94D3FBD5-0A74-4EE4-BE1A-C97E82ADFA33" }, "speaker": { "Identifier": 26, "DefaultDescription": "Speaker", "UUID": "C0F5EDC5-4003-464A-9E5D-0DB36677BC35" }, "bridge": { "Identifier": 2, "DefaultDescription": "Bridge", "UUID": "61102194-9993-48BF-A1EF-6C7DC50F0C01" }, "television-streaming-stick": { "Identifier": 36, "DefaultDescription": "Television Streaming Stick", "UUID": "B0C866C4-3E25-4F6A-8476-A8A3B579A86E" }, "door": { "Identifier": 12, "DefaultDescription": "Door", "UUID": "DD4DE411-8F01-44EE-866A-1F96144DC1B6" }, "door-lock": { "Identifier": 6, "DefaultDescription": "Door Lock", "UUID": "C25D5FCE-52EC-4599-A815-1192C5F08C7F" }, "thermostat": { "Identifier": 9, "DefaultDescription": "Thermostat", "UUID": "79668DCF-89FB-450D-94B5-AEE70B7B09F1" }, "switch": { "Identifier": 8, "DefaultDescription": "Switch", "UUID": "2F4C3164-8DE4-4A4F-93BA-DD1D5068DF0B" }, "sensor": { "Identifier": 10, "DefaultDescription": "Sensor", "UUID": "772AFB8E-8D2F-455E-90E5-9852E6C4DD31" }, "air-dehumidifier": { "Identifier": 23, "DefaultDescription": "Air Dehumidifier", "UUID": "1E15B639-DC98-41D4-A394-2E4A1D54AA3A" }, "ip-camera": { "Identifier": 17, "DefaultDescription": "IP Camera", "UUID": "C9EE63DB-2FF7-4514-826A-2FC2F0D4C9F0" }, "programmable-switch": { "Identifier": 15, "DefaultDescription": "Programmable Switch", "UUID": "3F9B944B-B8DF-4570-BAF5-CD31A8B321A7" }, "target-controller": { "Identifier": 32, "DefaultDescription": "Target Controller", "UUID": "770ADB51-8848-491A-BFA3-C34EA096CC92" }, "wifi-router": { "Identifier": 33, "DefaultDescription": "Wi-Fi Router", "UUID": "337635B4-552A-48AD-A38D-DD2D5E826C9A" }, "range-extender": { "Identifier": 16, "DefaultDescription": "Range Extender", "UUID": "8E33483E-2102-4BFE-9295-0A187D114188" }, "security-system": { "Identifier": 11, "DefaultDescription": "Security System", "UUID": "14D8FE28-2998-49E3-AC95-E3969BE2957C" } }, "AllowableSecuringWrites": { "security-system-state.target": [0, 1, 2], "lock-mechanism.target-state": [1], "position.target": [0], "door-state.target": [1] }, "RequiresDeviceUnlock": { "position.hold": ["door", "window"], "lock-mechanism.current-state": ["garage-door-opener", "lock-mechanism"], "position.state": ["door", "window"], "position.target": ["door", "window"], "lock-mechanism.target-state": ["garage-door-opener", "lock-mechanism"], "door-state.current": ["garage-door-opener"], "door-state.target": ["garage-door-opener"], "position.current": ["door", "window"], "security-system-state.current": ["security-system"], "security-system-state.target": ["security-system"] }, "Blacklist": { "Characteristics": [ "accessory.identifier", "cloud-relay.control-point", "cloud-relay.current-state", "cloud-relay.enabled", "list-pairings", "pair-setup", "pair-verify", "pairing-features", "service-signature" ], "Services": ["cloud-relay", "pairing", "protocol-information"] }, "BlacklistFromApplications": { "Characteristics": [ "access-code-control-point", "access-code-supported-configuration", "accessory-flags", "app-matching-identifier", "characteristic-value-active-transition-count", "characteristic-value-transition-control", "configuration-state", "display-order", "hardware-finish", "identifier", "managed-network-enable", "network-access-violation-control", "network-client-control", "network-client-status-control", "nfc-access-control-point", "nfc-access-supported-configuration", "operating-state-response", "password-setting", "privilege", "product-data", "router-status", "selected-audio-stream-configuration", "service-signature", "setup-data-stream-transport", "supported-characteristic-value-transition-configuration", "supported-data-stream-transport-configuration", "supported-router-configuration", "thread-control-point", "wake-configuration", "wan-configuration-list", "wan-status-list", "wifi-satellite-status" ], "Services": [ "access-code", "access-control", "assistant", "audio-stream-management", "camera-operating-mode", "camera-recording-management", "camera-rtp-stream-management", "data-stream-transport-management", "nfc-access", "power-management", "siri", "siri-endpoint", "smart-speaker", "target-control", "target-control-management", "wifi-router", "wifi-satellite" ] } }, "HAP": { "Base UUID": "-0000-1000-8000-0026BB765291", "Characteristics": { "siri-input-type": { "ShortUUID": "00000132", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Siri Input Type", "Properties": 2, "MaxValue": 1 }, "access-code-control-point": { "DefaultDescription": "Access Code Control Point", "Format": "tlv8", "ShortUUID": "00000262", "LocalizationKey": "", "Properties": 6 }, "wan-status-list": { "DefaultDescription": "WAN Status List", "Format": "tlv8", "ShortUUID": "00000212", "LocalizationKey": "", "Properties": 3 }, "multifunction-button": { "ShortUUID": "0000026B", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Multifunction Button", "Properties": 3, "MaxValue": 1 }, "in-use": { "ShortUUID": "000000D2", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "In Use", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "wifi-configuration-control": { "DefaultDescription": "Wi-Fi Configuration Control", "Format": "tlv8", "ShortUUID": "0000022D", "LocalizationKey": "", "Properties": 167 }, "rotation.speed": { "ShortUUID": "00000029", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Rotation Speed", "Properties": 7, "StepValue": 1, "MaxValue": 100 }, "supported-target-configuration": { "DefaultDescription": "Supported Target Configuration", "Format": "tlv8", "ShortUUID": "00000123", "LocalizationKey": "", "Properties": 2 }, "wake-configuration": { "DefaultDescription": "Wake Configuration", "Format": "tlv8", "ShortUUID": "00000222", "LocalizationKey": "", "Properties": 2 }, "rssi": { "DefaultDescription": "Received Signal Strength Indication", "Format": "int", "ShortUUID": "0000023F", "LocalizationKey": "", "Properties": 2 }, "setup-data-stream-transport": { "DefaultDescription": "Setup Data Stream Transport", "Format": "tlv8", "ShortUUID": "00000131", "LocalizationKey": "", "Properties": 6 }, "slat.type": { "ShortUUID": "000000C0", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Slat Type", "Properties": 2, "StepValue": 1, "MaxValue": 1 }, "temperature.units": { "ShortUUID": "00000036", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Temperature Display Units", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "air-purifier.state.target": { "ShortUUID": "000000A8", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Air Purifier State", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "density.voc": { "ShortUUID": "000000C8", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Volatile Organic Compound Density", "Properties": 3, "StepValue": 1, "MaxValue": 1000, "Units": "micrograms/m^3" }, "volume": { "ShortUUID": "00000119", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Volume", "Properties": 7, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "hue": { "ShortUUID": "00000013", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Hue", "Properties": 7, "StepValue": 1, "MaxValue": 360, "Units": "arcdegrees" }, "logs": { "DefaultDescription": "Logs", "Format": "tlv8", "ShortUUID": "0000001F", "LocalizationKey": "", "Properties": 3 }, "characteristic-value-active-transition-count": { "DefaultDescription": "Characteristic Value Active Transition Count", "Format": "uint8", "ShortUUID": "0000024B", "LocalizationKey": "", "Properties": 3 }, "firmware-update-readiness": { "DefaultDescription": "Firmware Update Readiness", "Format": "tlv8", "ShortUUID": "00000234", "LocalizationKey": "", "Properties": 3 }, "cloud-relay.enabled": { "DefaultDescription": "Cloud Relay Enable Status", "Format": "bool", "ShortUUID": "0000005B", "LocalizationKey": "", "Properties": 7 }, "selected-camera-recording-configuration": { "DefaultDescription": "Selected Camera Recording Configuration", "Format": "tlv8", "ShortUUID": "00000209", "LocalizationKey": "", "Properties": 7 }, "mac-transmission-counters": { "DefaultDescription": "MAC Transmission Counters", "Format": "data", "ShortUUID": "00000248", "LocalizationKey": "", "Properties": 2 }, "characteristic-value-transition-control": { "DefaultDescription": "Characteristic Value Transition Control", "Format": "tlv8", "ShortUUID": "00000143", "LocalizationKey": "", "Properties": 6 }, "filter.change-indication": { "ShortUUID": "000000AC", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Filter Change indication", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "position.current": { "ShortUUID": "0000006D", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Position", "Properties": 3, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "staged-firmware-version": { "DefaultDescription": "Staged Firmware Version", "Format": "string", "ShortUUID": "00000249", "LocalizationKey": "", "Properties": 3 }, "smoke-detected": { "ShortUUID": "00000076", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Smoke Detected", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "output-state": { "ShortUUID": "00000074", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Programmable Switch Output State", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "remaining-duration": { "ShortUUID": "000000D4", "MinValue": 0, "Format": "uint32", "LocalizationKey": "", "DefaultDescription": "Remaining Duration", "Properties": 3, "StepValue": 1, "MaxValue": 3600, "Units": "seconds" }, "manually-disabled": { "DefaultDescription": "Manually disabled", "Format": "bool", "ShortUUID": "00000227", "LocalizationKey": "", "Properties": 3 }, "horizontal-tilt.current": { "ShortUUID": "0000006C", "MinValue": -90, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Current Horizontal Tilt Angle", "Properties": 3, "StepValue": 1, "MaxValue": 90, "Units": "arcdegrees" }, "nfc-access-supported-configuration": { "DefaultDescription": "NFC Access Supported Configuration", "Format": "tlv8", "ShortUUID": "00000265", "LocalizationKey": "", "Properties": 2 }, "ping": { "DefaultDescription": "Ping", "Format": "data", "ShortUUID": "0000023C", "LocalizationKey": "", "Properties": 2 }, "digital-zoom": { "StepValue": 0.10000000000000001, "DefaultDescription": "Digital Zoom", "Format": "float", "ShortUUID": "0000011D", "LocalizationKey": "", "Properties": 7 }, "swing-mode": { "ShortUUID": "000000B6", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Swing Mode", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "access-code-supported-configuration": { "DefaultDescription": "Access Code Supported Configuration", "Format": "tlv8", "ShortUUID": "00000261", "LocalizationKey": "", "Properties": 2 }, "security-system-state.target": { "ShortUUID": "00000067", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Security System Target State", "Properties": 7, "StepValue": 1, "MaxValue": 3 }, "fan.state.current": { "ShortUUID": "000000AF", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Fan State", "Properties": 3, "StepValue": 1, "MaxValue": 2 }, "rotation.direction": { "ShortUUID": "00000028", "MinValue": 0, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Rotation Direction", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "sleep-discovery-mode": { "ShortUUID": "000000E8", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Sleep Discovery Mode", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "volume-control-type": { "ShortUUID": "000000E9", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Volume Control Type", "Properties": 3, "StepValue": 1, "MaxValue": 3 }, "input-source-type": { "ShortUUID": "000000DB", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Input Source Type", "Properties": 3, "StepValue": 1, "MaxValue": 10 }, "charging-state": { "ShortUUID": "0000008F", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Charging State", "Properties": 3, "StepValue": 1, "MaxValue": 2 }, "hardware-finish": { "DefaultDescription": "Hardware Finish", "Format": "tlv8", "ShortUUID": "0000026C", "LocalizationKey": "", "Properties": 2 }, "relative-humidity.target": { "ShortUUID": "00000034", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Target Relative Humidity", "Properties": 7, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "relative-humidity.dehumidifier-threshold": { "ShortUUID": "000000C9", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Relative Humidity Dehumidifier Threshold", "Properties": 7, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "color-temperature": { "ShortUUID": "000000CE", "MinValue": 140, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Color Temperature", "Properties": 7, "StepValue": 1, "MaxValue": 500 }, "pair-setup": { "DefaultDescription": "Pair Setup", "Format": "tlv8", "ShortUUID": "0000004C", "LocalizationKey": "", "Properties": 6 }, "supported-router-configuration": { "DefaultDescription": "Supported Router Configuration", "Format": "tlv8", "ShortUUID": "00000210", "LocalizationKey": "", "Properties": 2 }, "carbon-dioxide.detected": { "ShortUUID": "00000092", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Carbon dioxide Detected", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "light-level.current": { "ShortUUID": "0000006B", "MinValue": 0.0001, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Current Light Level", "Properties": 3, "MaxValue": 100000, "Units": "lux" }, "software.revision": { "DefaultDescription": "Software Revision", "Format": "string", "ShortUUID": "00000054", "LocalizationKey": "", "Properties": 2 }, "event-transmission-counters": { "DefaultDescription": "Event Transmission Counters", "Format": "uint32", "ShortUUID": "0000023E", "LocalizationKey": "", "Properties": 2 }, "is-configured": { "ShortUUID": "000000D6", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Is Configured", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "wan-configuration-list": { "DefaultDescription": "WAN Configuration List", "Format": "tlv8", "ShortUUID": "00000211", "LocalizationKey": "", "Properties": 3 }, "security-system-state.current": { "ShortUUID": "00000066", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Security System Current State", "Properties": 3, "StepValue": 1, "MaxValue": 4 }, "homekit-camera-active": { "DefaultDescription": "HomeKit Camera Active", "Format": "bool", "ShortUUID": "0000021B", "LocalizationKey": "", "Properties": 39 }, "optical-zoom": { "StepValue": 0.10000000000000001, "DefaultDescription": "Optical Zoom", "Format": "float", "ShortUUID": "0000011C", "LocalizationKey": "", "Properties": 7 }, "mute": { "DefaultDescription": "Mute", "Format": "bool", "ShortUUID": "0000011A", "LocalizationKey": "", "Properties": 7 }, "event-snapshots-active": { "DefaultDescription": "Event Snapshots Active", "Format": "bool", "ShortUUID": "00000223", "LocalizationKey": "", "Properties": 39 }, "service-signature": { "DefaultDescription": "Service Signature", "Format": "tlv8", "ShortUUID": "000000A5", "LocalizationKey": "", "Properties": 6 }, "temperature.current": { "ShortUUID": "00000011", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Current Temperature", "Properties": 3, "StepValue": 0.10000000000000001, "MaxValue": 100, "Units": "celsius" }, "cloud-relay.control-point": { "DefaultDescription": "Cloud Relay Control Point", "Format": "tlv8", "ShortUUID": "0000005E", "LocalizationKey": "", "Properties": 7 }, "supported-firmware-update-configuration": { "DefaultDescription": "Supported Firmware Update Configuration", "Format": "tlv8", "ShortUUID": "00000233", "LocalizationKey": "", "Properties": 2 }, "name": { "DefaultDescription": "Name", "MaxLength": 64, "Format": "string", "ShortUUID": "00000023", "LocalizationKey": "", "Properties": 2 }, "receiver-sensitivity": { "DefaultDescription": "Receiver Sensitivity", "Format": "int", "ShortUUID": "00000244", "LocalizationKey": "", "Properties": 2 }, "active-identifier": { "DefaultDescription": "Active Identifier", "MinValue": 0, "Format": "uint32", "ShortUUID": "000000E7", "LocalizationKey": "", "Properties": 7 }, "density.so2": { "ShortUUID": "000000C5", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Sulphur dioxide Density", "Properties": 3, "StepValue": 1, "MaxValue": 1000, "Units": "micrograms/m^3" }, "relative-humidity.current": { "ShortUUID": "00000010", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Current Relative Humidity", "Properties": 3, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "obstruction-detected": { "DefaultDescription": "Obstruction Detected", "Format": "bool", "ShortUUID": "00000024", "LocalizationKey": "", "Properties": 3 }, "operating-state-response": { "DefaultDescription": "Operating State Response", "Format": "tlv8", "ShortUUID": "00000232", "LocalizationKey": "", "Properties": 3 }, "supported-diagnostics-snapshot": { "DefaultDescription": "Supported Diagnostics Snapshot", "Format": "tlv8", "ShortUUID": "00000238", "LocalizationKey": "", "Properties": 2 }, "on": { "DefaultDescription": "Power State", "Format": "bool", "ShortUUID": "00000025", "LocalizationKey": "", "Properties": 7 }, "supported-audio-recording-configuration": { "DefaultDescription": "Supported Audio Recording Configuration", "Format": "tlv8", "ShortUUID": "00000207", "LocalizationKey": "", "Properties": 3 }, "active": { "ShortUUID": "000000B0", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Active", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "heating-cooling.current": { "ShortUUID": "0000000F", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Heating Cooling State", "Properties": 3, "StepValue": 1, "MaxValue": 2 }, "accessory-flags": { "DefaultDescription": "Accessory Flags", "Format": "uint32", "ShortUUID": "000000A6", "LocalizationKey": "", "Properties": 3 }, "motion-detected": { "DefaultDescription": "Motion Detected", "Format": "bool", "ShortUUID": "00000022", "LocalizationKey": "", "Properties": 3 }, "camera-operating-mode-indicator": { "DefaultDescription": "Camera Operating Mode Indicator", "Format": "bool", "ShortUUID": "0000021D", "LocalizationKey": "", "Properties": 39 }, "periodic-snapshots-active": { "DefaultDescription": "Periodic Snapshots Active", "Format": "bool", "ShortUUID": "00000225", "LocalizationKey": "", "Properties": 39 }, "service-label-index": { "ShortUUID": "000000CB", "MinValue": 1, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Label Index", "Properties": 2, "StepValue": 1, "MaxValue": 255 }, "lock-mechanism.target-state": { "ShortUUID": "0000001E", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Lock Target State", "Properties": 23, "StepValue": 1, "MaxValue": 1 }, "accessory.identifier": { "DefaultDescription": "Accessory Identifier", "Format": "string", "ShortUUID": "00000057", "LocalizationKey": "", "Properties": 2 }, "app-matching-identifier": { "DefaultDescription": "Application Matching Identifier", "Format": "tlv8", "ShortUUID": "000000A4", "LocalizationKey": "", "Properties": 2 }, "list-pairings": { "DefaultDescription": "List Pairings", "Format": "tlv8", "ShortUUID": "00000050", "LocalizationKey": "", "Properties": 6 }, "siri-listening": { "ShortUUID": "00000256", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Siri Listening", "Properties": 7, "MaxValue": 1 }, "product-data": { "DefaultDescription": "Product Data", "Format": "data", "ShortUUID": "00000220", "LocalizationKey": "", "Properties": 2 }, "water-level": { "ShortUUID": "000000B5", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Current Water Level", "Properties": 3, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "wifi-satellite-status": { "ShortUUID": "0000021E", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Wi-Fi Satellite Status", "Properties": 3, "MaxValue": 2 }, "model": { "DefaultDescription": "Model", "MaxLength": 64, "Format": "string", "ShortUUID": "00000021", "LocalizationKey": "", "Properties": 2 }, "heater-cooler.state.target": { "ShortUUID": "000000B2", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Heater-Cooler State", "Properties": 7, "StepValue": 1, "MaxValue": 2 }, "media-state.target": { "ShortUUID": "00000137", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Media State", "Properties": 7, "StepValue": 1, "MaxValue": 2 }, "router-status": { "ShortUUID": "0000020E", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Router Status", "Properties": 3, "MaxValue": 1 }, "power-mode-selection": { "ShortUUID": "000000DF", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Power Mode Selection", "Properties": 4, "StepValue": 1, "MaxValue": 1 }, "battery-level": { "ShortUUID": "00000068", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Battery Level", "Properties": 3, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "firmware-update-status": { "DefaultDescription": "Firmware Update Status", "Format": "tlv8", "ShortUUID": "00000235", "LocalizationKey": "", "Properties": 3 }, "setup-stream-endpoint": { "DefaultDescription": "Setup Endpoint", "Format": "tlv8", "ShortUUID": "00000118", "LocalizationKey": "", "Properties": 6 }, "input-device-type": { "ShortUUID": "000000DC", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Input Device Type", "Properties": 3, "StepValue": 1, "MaxValue": 6 }, "carbon-dioxide.level": { "ShortUUID": "00000093", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Carbon dioxide Level", "Properties": 3, "StepValue": 1, "MaxValue": 100000, "Units": "ppm" }, "streaming-status": { "DefaultDescription": "Streaming Status", "Format": "tlv8", "ShortUUID": "00000120", "LocalizationKey": "", "Properties": 3 }, "lock-mechanism.last-known-action": { "ShortUUID": "0000001C", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Lock Last Known Action", "Properties": 3, "StepValue": 1, "MaxValue": 8 }, "density.pm2_5": { "ShortUUID": "000000C6", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "PM2.5 Density", "Properties": 3, "StepValue": 1, "MaxValue": 1000, "Units": "micrograms/m^3" }, "air-purifier.state.current": { "ShortUUID": "000000A9", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Air Purifier State", "Properties": 3, "StepValue": 1, "MaxValue": 2 }, "video-analysis-active": { "DefaultDescription": "Video Analysis Active", "Format": "uint8", "ShortUUID": "00000229", "LocalizationKey": "", "Properties": 7 }, "slat.state.current": { "ShortUUID": "000000AA", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Slat State", "Properties": 3, "StepValue": 1, "MaxValue": 3 }, "asset-update-readiness": { "DefaultDescription": "Asset Update Readiness", "Format": "uint32", "ShortUUID": "00000269", "LocalizationKey": "", "Properties": 3 }, "button-event": { "DefaultDescription": "Button Event", "Format": "tlv8", "ShortUUID": "00000126", "LocalizationKey": "", "Properties": 3 }, "carbon-monoxide.peak-level": { "ShortUUID": "00000091", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Carbon monoxide Peak Level", "Properties": 3, "StepValue": 1, "MaxValue": 100, "Units": "ppm" }, "air-particulate.density": { "ShortUUID": "00000064", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Air Particulate Density", "Properties": 3, "MaxValue": 1000, "Units": "micrograms/m^3" }, "supported-characteristic-value-transition-configuration": { "DefaultDescription": "Supported Characteristic Value Transition Configuration", "Format": "tlv8", "ShortUUID": "00000144", "LocalizationKey": "", "Properties": 2 }, "selected-stream-configuration": { "DefaultDescription": "Selected Stream Configuration", "Format": "tlv8", "ShortUUID": "00000117", "LocalizationKey": "", "Properties": 6 }, "humidifier-dehumidifier.state.target": { "ShortUUID": "000000B4", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Humidifier-Dehumidifier State", "Properties": 7, "StepValue": 1, "MaxValue": 2 }, "airplay-enable": { "ShortUUID": "0000025B", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "AirPlay Enable", "Properties": 7, "MaxValue": 1 }, "heart-beat": { "DefaultDescription": "Heart Beat", "Format": "uint32", "ShortUUID": "0000024A", "LocalizationKey": "", "Properties": 3 }, "sleep-interval": { "ShortUUID": "0000023A", "MinValue": 0, "Format": "uint32", "LocalizationKey": "", "DefaultDescription": "Sleep Interval", "StepValue": 1, "Properties": 3 }, "pair-verify": { "DefaultDescription": "Pair Verify", "Format": "tlv8", "ShortUUID": "0000004E", "LocalizationKey": "", "Properties": 6 }, "supported-video-stream-configuration": { "DefaultDescription": "Supported Video Stream Configuration", "Format": "tlv8", "ShortUUID": "00000114", "LocalizationKey": "", "Properties": 2 }, "tilt.current": { "ShortUUID": "000000C1", "MinValue": -90, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Current Tilt Angle", "Properties": 3, "StepValue": 1, "MaxValue": 90, "Units": "arcdegrees" }, "supported-audio-stream-configuration": { "DefaultDescription": "Supported Audio Stream Configuration", "Format": "tlv8", "ShortUUID": "00000115", "LocalizationKey": "", "Properties": 2 }, "lock-management.control-point": { "DefaultDescription": "Lock Control Point", "Format": "tlv8", "ShortUUID": "00000019", "LocalizationKey": "", "Properties": 4 }, "hardware.revision": { "DefaultDescription": "Hardware Revision", "Format": "string", "ShortUUID": "00000053", "LocalizationKey": "", "Properties": 2 }, "transmit-power": { "DefaultDescription": "Transmit Power", "Format": "int", "ShortUUID": "00000242", "LocalizationKey": "", "Properties": 2 }, "density.ozone": { "ShortUUID": "000000C3", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Ozone Density", "Properties": 3, "StepValue": 1, "MaxValue": 1000, "Units": "micrograms/m^3" }, "brightness": { "ShortUUID": "00000008", "MinValue": 0, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Brightness", "Properties": 7, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "humidifier-dehumidifier.state.current": { "ShortUUID": "000000B3", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Humidifier-Dehumidifier State", "Properties": 3, "StepValue": 1, "MaxValue": 3 }, "carbon-monoxide.detected": { "ShortUUID": "00000069", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Carbon monoxide Detected", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "network-access-violation-control": { "DefaultDescription": "Network Access Violation Control", "Format": "tlv8", "ShortUUID": "0000021F", "LocalizationKey": "", "Properties": 167 }, "data-stream-hap-transport": { "DefaultDescription": "Data Stream HAP Transport", "Format": "tlv8", "ShortUUID": "00000138", "LocalizationKey": "", "Properties": 6 }, "door-state.current": { "ShortUUID": "0000000E", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Door State", "Properties": 3, "StepValue": 1, "MaxValue": 4 }, "pairing-features": { "DefaultDescription": "Pairing Features", "Format": "uint8", "ShortUUID": "0000004F", "LocalizationKey": "", "Properties": 6 }, "cca-energy-detect-threshold": { "DefaultDescription": "CCA Energy Detect Threshold", "Format": "int", "ShortUUID": "00000246", "LocalizationKey": "", "Properties": 2 }, "filter.life-level": { "ShortUUID": "000000AB", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Filter Life Level", "Properties": 3, "StepValue": 1, "MaxValue": 100 }, "selected-audio-stream-configuration": { "DefaultDescription": "Selected Audio Stream Configuration", "Format": "tlv8", "ShortUUID": "00000128", "LocalizationKey": "", "Properties": 6 }, "density.pm10": { "ShortUUID": "000000C7", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "PM10 Density", "Properties": 3, "StepValue": 1, "MaxValue": 1000, "Units": "micrograms/m^3" }, "volume-selector": { "ShortUUID": "000000EA", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Volume Selector", "Properties": 4, "StepValue": 1, "MaxValue": 1 }, "version": { "DefaultDescription": "Version", "MaxLength": 64, "Format": "string", "ShortUUID": "00000037", "LocalizationKey": "", "Properties": 3 }, "administrator-only-access": { "DefaultDescription": "Administrator Only Access", "Format": "bool", "ShortUUID": "00000001", "LocalizationKey": "", "Properties": 7 }, "configuration-state": { "DefaultDescription": "Configuration State", "Format": "uint16", "ShortUUID": "00000263", "LocalizationKey": "", "Properties": 3 }, "setup-transfer-transport": { "DefaultDescription": "Setup Transfer Transport", "Format": "tlv8", "ShortUUID": "00000201", "LocalizationKey": "", "Properties": 132 }, "thread-control-point": { "DefaultDescription": "Thread Control Point", "Format": "tlv8", "ShortUUID": "00000704", "LocalizationKey": "", "Properties": 4 }, "identifier": { "DefaultDescription": "Identifier", "MinValue": 0, "Format": "uint32", "ShortUUID": "000000E6", "LocalizationKey": "", "Properties": 2 }, "firmware.revision": { "DefaultDescription": "Firmware Revision", "Format": "string", "ShortUUID": "00000052", "LocalizationKey": "", "Properties": 2 }, "carbon-dioxide.peak-level": { "ShortUUID": "00000094", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Carbon dioxide Peak Level", "Properties": 3, "StepValue": 1, "MaxValue": 100000, "Units": "ppm" }, "carbon-monoxide.level": { "ShortUUID": "00000090", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Carbon monoxide Level", "Properties": 3, "StepValue": 1, "MaxValue": 100, "Units": "ppm" }, "target-list": { "DefaultDescription": "Target List Configuration", "Format": "tlv8", "ShortUUID": "00000124", "LocalizationKey": "", "Properties": 134 }, "network-client-status-control": { "DefaultDescription": "Network Client Status Control", "Format": "tlv8", "ShortUUID": "0000020D", "LocalizationKey": "", "Properties": 134 }, "valve-type": { "ShortUUID": "000000D5", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Valve Type", "Properties": 3, "StepValue": 1, "MaxValue": 3 }, "mac-retransmission-maximum": { "DefaultDescription": "MAC Retransmission Maximum", "Format": "uint8", "ShortUUID": "00000247", "LocalizationKey": "", "Properties": 2 }, "configured-name": { "DefaultDescription": "Configured Name", "Format": "string", "ShortUUID": "000000E3", "LocalizationKey": "", "Properties": 3 }, "network-client-control": { "DefaultDescription": "Network Client Control", "Format": "tlv8", "ShortUUID": "0000020C", "LocalizationKey": "", "Properties": 167 }, "heating-cooling.target": { "ShortUUID": "00000033", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Heating Cooling State", "Properties": 7, "StepValue": 1, "MaxValue": 3 }, "lock-physical-controls": { "ShortUUID": "000000A7", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Lock Physical Controls", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "third-party-camera-active": { "DefaultDescription": "Third Party Camera Active", "Format": "bool", "ShortUUID": "0000021C", "LocalizationKey": "", "Properties": 3 }, "filter.reset-indication": { "ShortUUID": "000000AD", "MinValue": 1, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Filter Reset Change Indication", "Properties": 4, "StepValue": 1, "MaxValue": 1 }, "air-quality": { "ShortUUID": "00000095", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Air Quality", "Properties": 3, "StepValue": 1, "MaxValue": 5 }, "density.no2": { "ShortUUID": "000000C4", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Nitrogen dioxide Density", "Properties": 3, "StepValue": 1, "MaxValue": 1000, "Units": "micrograms/m^3" }, "supported-data-stream-transport-configuration": { "DefaultDescription": "Supported Data Stream Transport Configuration", "Format": "tlv8", "ShortUUID": "00000130", "LocalizationKey": "", "Properties": 2 }, "position.target": { "ShortUUID": "0000007C", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Position", "Properties": 7, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "image-rotation": { "ShortUUID": "0000011E", "MinValue": 0, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Image Rotation", "Properties": 7, "StepValue": 1, "MaxValue": 360, "Units": "arcdegrees" }, "cloud-relay.current-state": { "ShortUUID": "0000005C", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Cloud Relay Current State", "Properties": 3, "StepValue": 1, "MaxValue": 5 }, "status-jammed": { "ShortUUID": "00000078", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Status Jammed", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "vertical-tilt.target": { "ShortUUID": "0000007D", "MinValue": -90, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Target Vertical Tilt Angle", "Properties": 7, "StepValue": 1, "MaxValue": 90, "Units": "arcdegrees" }, "picture-mode": { "ShortUUID": "000000E2", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Picture Mode", "Properties": 7, "StepValue": 1, "MaxValue": 13 }, "input-event": { "ShortUUID": "00000073", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Programmable Switch Event", "Properties": 3, "StepValue": 1, "MaxValue": 2 }, "selected-diagnostics-modes": { "DefaultDescription": "Selected Diagnostics Modes", "Format": "uint32", "ShortUUID": "0000024D", "LocalizationKey": "", "Properties": 6 }, "identify": { "DefaultDescription": "Identify", "Format": "bool", "ShortUUID": "00000014", "LocalizationKey": "", "Properties": 4 }, "outlet-in-use": { "DefaultDescription": "Outlet In Use", "Format": "bool", "ShortUUID": "00000026", "LocalizationKey": "", "Properties": 3 }, "service-label-namespace": { "ShortUUID": "000000CD", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Label Namespace", "Properties": 2, "StepValue": 1, "MaxValue": 4 }, "leak-detected": { "ShortUUID": "00000070", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Leak Detected", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "lock-mechanism.current-state": { "ShortUUID": "0000001D", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Lock Current State", "Properties": 3, "StepValue": 1, "MaxValue": 3 }, "media-state.current": { "ShortUUID": "000000E0", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Media State", "Properties": 3, "StepValue": 1, "MaxValue": 5 }, "display-order": { "DefaultDescription": "Display Order", "Format": "tlv8", "ShortUUID": "00000136", "LocalizationKey": "", "Properties": 3 }, "contact-state": { "ShortUUID": "0000006A", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Contact Sensor State", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "data-stream-hap-transport-interrupt": { "DefaultDescription": "Data Stream HAP Transport Interrupt", "Format": "tlv8", "ShortUUID": "00000139", "LocalizationKey": "", "Properties": 3 }, "siri-enable": { "ShortUUID": "00000255", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Siri Enable", "Properties": 7, "MaxValue": 1 }, "horizontal-tilt.target": { "ShortUUID": "0000007B", "MinValue": -90, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Target Horizontal Tilt Angle", "Properties": 7, "StepValue": 1, "MaxValue": 90, "Units": "arcdegrees" }, "supported-transfer-transport-configuration": { "DefaultDescription": "Supported Transfer Transport Configuration", "Format": "tlv8", "ShortUUID": "00000202", "LocalizationKey": "", "Properties": 2 }, "relative-humidity.humidifier-threshold": { "ShortUUID": "000000CA", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Relative Humidity Humidifier Threshold", "Properties": 7, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "position.state": { "ShortUUID": "00000072", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Position State", "Properties": 3, "StepValue": 1, "MaxValue": 2 }, "status-fault": { "ShortUUID": "00000077", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Status Fault", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "password-setting": { "DefaultDescription": "Password Setting", "Format": "tlv8", "ShortUUID": "000000E4", "LocalizationKey": "", "Properties": 7 }, "security-system.alarm-type": { "ShortUUID": "0000008E", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Security System Alarm Type", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "event-retransmission-maximum": { "DefaultDescription": "Event Retransmission Maximum", "Format": "uint8", "ShortUUID": "0000023D", "LocalizationKey": "", "Properties": 2 }, "cca-signal-detect-threshold": { "DefaultDescription": "CCA Signal Detect Threshold", "Format": "int", "ShortUUID": "00000245", "LocalizationKey": "", "Properties": 2 }, "supported-diagnostics-modes": { "DefaultDescription": "Supported Diagnostics Modes", "Format": "uint32", "ShortUUID": "0000024C", "LocalizationKey": "", "Properties": 2 }, "temperature.cooling-threshold": { "ShortUUID": "0000000D", "MinValue": 10, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Cooling Threshold Temperature", "Properties": 7, "StepValue": 0.10000000000000001, "MaxValue": 35, "Units": "celsius" }, "snr": { "DefaultDescription": "Signal-to-noise Ratio", "Format": "int", "ShortUUID": "00000241", "LocalizationKey": "", "Properties": 2 }, "thread-openthread-version": { "DefaultDescription": "Thread OpenThread Version", "Format": "string", "ShortUUID": "00000706", "LocalizationKey": "", "Properties": 2 }, "privilege": { "ShortUUID": "000000E5", "MinValue": 0, "Format": "uint16", "LocalizationKey": "", "DefaultDescription": "Access Control Level", "Properties": 7, "StepValue": 1, "MaxValue": 2 }, "siri-endpoint-session-status": { "DefaultDescription": "Siri Endpoint Session Status", "Format": "tlv8", "ShortUUID": "00000254", "LocalizationKey": "", "Properties": 3 }, "nfc-access-control-point": { "DefaultDescription": "NFC Access Control Point", "Format": "tlv8", "ShortUUID": "00000264", "LocalizationKey": "", "Properties": 6 }, "siri-touch-to-use": { "ShortUUID": "00000257", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Siri Touch To Use", "Properties": 7, "MaxValue": 1 }, "transmit-power-maximum": { "DefaultDescription": "Maximum Transmit Power", "Format": "int", "ShortUUID": "00000243", "LocalizationKey": "", "Properties": 2 }, "serial-number": { "ShortUUID": "00000030", "Format": "string", "LocalizationKey": "", "DefaultDescription": "Serial Number", "MaxLength": 64, "Properties": 2, "MinLength": 1 }, "visibility-state.target": { "ShortUUID": "00000134", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Visibility State", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "visibility-state.current": { "ShortUUID": "00000135", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Visibility State", "Properties": 3, "StepValue": 1, "MaxValue": 3 }, "vertical-tilt.current": { "ShortUUID": "0000006E", "MinValue": -90, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Current Vertical Tilt Angle", "Properties": 3, "StepValue": 1, "MaxValue": 90, "Units": "arcdegrees" }, "door-state.target": { "ShortUUID": "00000032", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Door State", "Properties": 23, "StepValue": 1, "MaxValue": 1 }, "supported-rtp-configuration": { "DefaultDescription": "Supported RTP Configuration", "Format": "tlv8", "ShortUUID": "00000116", "LocalizationKey": "", "Properties": 2 }, "heater-cooler.state.current": { "ShortUUID": "000000B1", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Current Heater-Cooler State", "Properties": 3, "StepValue": 1, "MaxValue": 3 }, "fan.state.target": { "ShortUUID": "000000BF", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Target Fan State", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "status-tampered": { "ShortUUID": "0000007A", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Status Tampered", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "temperature.target": { "ShortUUID": "00000035", "MinValue": 10, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Target Temperature", "Properties": 7, "StepValue": 0.10000000000000001, "MaxValue": 38, "Units": "celsius" }, "thread-status": { "ShortUUID": "00000703", "MinValue": 0, "Format": "uint16", "LocalizationKey": "", "DefaultDescription": "Thread Status", "Properties": 3, "StepValue": 1, "MaxValue": 6 }, "tilt.target": { "ShortUUID": "000000C2", "MinValue": -90, "Format": "int", "LocalizationKey": "", "DefaultDescription": "Target Tilt Angle", "Properties": 7, "StepValue": 1, "MaxValue": 90, "Units": "arcdegrees" }, "status-lo-batt": { "ShortUUID": "00000079", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Status Low Battery", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "managed-network-enable": { "ShortUUID": "00000215", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Managed Network Enable", "Properties": 39, "MaxValue": 1 }, "air-particulate.size": { "ShortUUID": "00000065", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Air Particulate Size", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "saturation": { "ShortUUID": "0000002F", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Saturation", "Properties": 7, "StepValue": 1, "MaxValue": 100, "Units": "percentage" }, "siri-light-on-use": { "ShortUUID": "00000258", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Siri Light On Use", "Properties": 7, "MaxValue": 1 }, "status-active": { "DefaultDescription": "Status Active", "Format": "bool", "ShortUUID": "00000075", "LocalizationKey": "", "Properties": 3 }, "supported-camera-recording-configuration": { "DefaultDescription": "Supported Camera Recording Configuration", "Format": "tlv8", "ShortUUID": "00000205", "LocalizationKey": "", "Properties": 3 }, "activity-interval": { "ShortUUID": "0000023B", "MinValue": 0, "Format": "uint32", "LocalizationKey": "", "DefaultDescription": "Activity Interval", "StepValue": 1, "Properties": 3 }, "set-duration": { "ShortUUID": "000000D3", "MinValue": 0, "Format": "uint32", "LocalizationKey": "", "DefaultDescription": "Set Duration", "Properties": 7, "StepValue": 1, "MaxValue": 3600, "Units": "seconds" }, "wifi-capabilities": { "DefaultDescription": "Wi-Fi Capabilities", "Format": "uint32", "ShortUUID": "0000022C", "LocalizationKey": "", "Properties": 2 }, "occupancy-detected": { "ShortUUID": "00000071", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Occupancy Detected", "Properties": 3, "StepValue": 1, "MaxValue": 1 }, "audio-feedback": { "DefaultDescription": "Audio Feedback", "Format": "bool", "ShortUUID": "00000005", "LocalizationKey": "", "Properties": 7 }, "supported-video-recording-configuration": { "DefaultDescription": "Supported Video Recording Configuration", "Format": "tlv8", "ShortUUID": "00000206", "LocalizationKey": "", "Properties": 3 }, "current-transport": { "DefaultDescription": "Current Transport", "Format": "bool", "ShortUUID": "0000022B", "LocalizationKey": "", "Properties": 2 }, "manufacturer": { "DefaultDescription": "Manufacturer", "MaxLength": 64, "Format": "string", "ShortUUID": "00000020", "LocalizationKey": "", "Properties": 2 }, "thread-node-capabilities": { "ShortUUID": "00000702", "MinValue": 0, "Format": "uint16", "LocalizationKey": "", "DefaultDescription": "Thread Node Capabilities", "Properties": 2, "StepValue": 1, "MaxValue": 31 }, "night-vision": { "DefaultDescription": "Night Vision", "Format": "bool", "ShortUUID": "0000011B", "LocalizationKey": "", "Properties": 39 }, "closed-captions": { "ShortUUID": "000000DD", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Closed Captions", "Properties": 7, "StepValue": 1, "MaxValue": 1 }, "lock-management.auto-secure-timeout": { "Properties": 7, "DefaultDescription": "Lock Management Auto Security Timeout", "Format": "uint32", "ShortUUID": "0000001A", "Units": "seconds", "LocalizationKey": "" }, "recording-audio-active": { "DefaultDescription": "recording audio active", "Format": "uint8", "ShortUUID": "00000226", "LocalizationKey": "", "Properties": 39 }, "program-mode": { "ShortUUID": "000000D1", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Program Mode", "Properties": 3, "StepValue": 1, "MaxValue": 2 }, "image-mirroring": { "DefaultDescription": "Image Mirroring", "Format": "bool", "ShortUUID": "0000011F", "LocalizationKey": "", "Properties": 7 }, "siri-engine-revision": { "DefaultDescription": "Siri Engine Version", "Format": "string", "ShortUUID": "0000025A", "LocalizationKey": "", "Properties": 2 }, "position.hold": { "DefaultDescription": "Hold Position", "Format": "bool", "ShortUUID": "0000006F", "LocalizationKey": "", "Properties": 4 }, "remote-key": { "ShortUUID": "000000E1", "MinValue": 0, "Format": "uint8", "LocalizationKey": "", "DefaultDescription": "Remote Key", "Properties": 4, "StepValue": 1, "MaxValue": 16 }, "supported-asset-types": { "DefaultDescription": "Supported Asset Types", "Format": "uint32", "ShortUUID": "00000268", "LocalizationKey": "", "Properties": 2 }, "temperature.heating-threshold": { "ShortUUID": "00000012", "MinValue": 0, "Format": "float", "LocalizationKey": "", "DefaultDescription": "Heating Threshold Temperature", "Properties": 7, "StepValue": 0.10000000000000001, "MaxValue": 25, "Units": "celsius" } }, "Properties": { "hidden": { "LocalizationKey": "", "DefaultDescription": "Hidden", "Position": 6 }, "notify": { "LocalizationKey": "", "DefaultDescription": "Notify", "Position": 0 }, "write": { "LocalizationKey": "", "DefaultDescription": "Write", "Position": 2 }, "timedWrite": { "LocalizationKey": "", "DefaultDescription": "Timed Write Required", "Position": 5 }, "aa": { "LocalizationKey": "", "DefaultDescription": "Additional Authorization Needed", "Position": 4 }, "read": { "LocalizationKey": "", "DefaultDescription": "Read", "Position": 1 }, "adminOnly": { "LocalizationKey": "", "DefaultDescription": "Admin Only", "Position": 8 }, "broadcast": { "LocalizationKey": "", "DefaultDescription": "Broadcast State Changes", "Position": 3 }, "writeResponse": { "LocalizationKey": "", "DefaultDescription": "Write Response Needed", "Position": 7 } }, "Units": { "lux": { "DefaultDescription": "Lux", "LocalizationKey": "" }, "micrograms/m^3": { "DefaultDescription": "Micrograms Per Cubic Meter", "LocalizationKey": "" }, "celsius": { "DefaultDescription": "Celsius", "LocalizationKey": "" }, "seconds": { "DefaultDescription": "Seconds", "LocalizationKey": "" }, "fahrenheit": { "DefaultDescription": "Fahrenheit", "LocalizationKey": "" }, "ppm": { "DefaultDescription": "Parts Per Million", "LocalizationKey": "" }, "percentage": { "DefaultDescription": "Percentage", "LocalizationKey": "" }, "arcdegrees": { "DefaultDescription": "ArcDegrees", "LocalizationKey": "" } }, "SupportsAuthorizationData": { "door-state.target": ["garage-door-opener"], "lock-mechanism.target-state": ["garage-door-opener", "lock-mechanism"] }, "Services": { "assistant": { "Characteristics": { "Required": ["active", "identifier", "name"] }, "LocalizationKey": "", "ShortUUID": "0000026A", "DefaultDescription": "Assistant" }, "stateful-programmable-switch": { "Characteristics": { "Required": ["input-event", "output-state"], "Optional": ["name"] }, "LocalizationKey": "", "ShortUUID": "00000088", "DefaultDescription": "Stateful Programmable Switch" }, "camera-operating-mode": { "Characteristics": { "Required": ["event-snapshots-active", "homekit-camera-active"], "Optional": [ "camera-operating-mode-indicator", "manually-disabled", "night-vision", "periodic-snapshots-active", "third-party-camera-active" ] }, "LocalizationKey": "", "ShortUUID": "0000021A", "DefaultDescription": "Camera Operating Mode" }, "humidifier-dehumidifier": { "Characteristics": { "Required": [ "active", "humidifier-dehumidifier.state.current", "humidifier-dehumidifier.state.target", "relative-humidity.current" ], "Optional": [ "lock-physical-controls", "name", "relative-humidity.dehumidifier-threshold", "relative-humidity.humidifier-threshold", "rotation.speed", "swing-mode", "water-level" ] }, "LocalizationKey": "", "ShortUUID": "000000BD", "DefaultDescription": "Humidifier-Dehumidifier" }, "stateless-programmable-switch": { "Characteristics": { "Required": ["input-event"], "Optional": ["name", "service-label-index"] }, "LocalizationKey": "", "ShortUUID": "00000089", "DefaultDescription": "Stateless Programmable Switch" }, "nfc-access": { "Characteristics": { "Required": ["configuration-state", "nfc-access-control-point", "nfc-access-supported-configuration"] }, "LocalizationKey": "", "ShortUUID": "00000266", "DefaultDescription": "NFC Access Service" }, "sensor.motion": { "Characteristics": { "Required": ["motion-detected"], "Optional": ["name", "status-active", "status-fault", "status-lo-batt", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "00000085", "DefaultDescription": "Motion Sensor" }, "speaker": { "Characteristics": { "Required": ["mute"], "Optional": ["active", "volume", "volume-control-type", "volume-selector"] }, "LocalizationKey": "", "ShortUUID": "00000113", "DefaultDescription": "Speaker" }, "metrics": { "Characteristics": { "Required": ["active"] }, "LocalizationKey": "", "ShortUUID": "00000270", "DefaultDescription": "Accessory Metrics" }, "input-source": { "Characteristics": { "Required": ["configured-name", "input-source-type", "is-configured", "name", "visibility-state.current"], "Optional": ["identifier", "input-device-type", "visibility-state.target"] }, "LocalizationKey": "", "ShortUUID": "000000D9", "DefaultDescription": "Input Source" }, "accessory-runtime-information": { "Characteristics": { "Required": ["ping"], "Optional": ["activity-interval", "heart-beat", "sleep-interval"] }, "LocalizationKey": "", "ShortUUID": "00000239", "DefaultDescription": "Accessory Runtime Information" }, "sensor.light": { "Characteristics": { "Required": ["light-level.current"], "Optional": ["name", "status-active", "status-fault", "status-lo-batt", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "00000084", "DefaultDescription": "Light Sensor" }, "fan": { "DefaultDescription": "Fan", "Characteristics": { "Required": ["on"], "Optional": ["name", "rotation.direction", "rotation.speed"] }, "ShortUUID": "00000040", "LocalizationKey": "", "BTLE_ShortUUID": "FECB" }, "filter-maintenance": { "Characteristics": { "Required": ["filter.change-indication"], "Optional": ["filter.life-level", "filter.reset-indication", "name"] }, "LocalizationKey": "", "ShortUUID": "000000BA", "DefaultDescription": "Filter Maintenance" }, "sensor.carbon-dioxide": { "Characteristics": { "Required": ["carbon-dioxide.detected"], "Optional": [ "carbon-dioxide.level", "carbon-dioxide.peak-level", "name", "status-active", "status-fault", "status-lo-batt", "status-tampered" ] }, "LocalizationKey": "", "ShortUUID": "00000097", "DefaultDescription": "Carbon dioxide Sensor" }, "valve": { "Characteristics": { "Required": ["active", "in-use", "valve-type"], "Optional": [ "is-configured", "name", "remaining-duration", "service-label-index", "set-duration", "status-fault" ] }, "LocalizationKey": "", "ShortUUID": "000000D0", "DefaultDescription": "Valve" }, "thread-transport": { "Characteristics": { "Required": ["current-transport", "thread-control-point", "thread-node-capabilities", "thread-status"], "Optional": [ "cca-energy-detect-threshold", "cca-signal-detect-threshold", "event-retransmission-maximum", "event-transmission-counters", "mac-retransmission-maximum", "mac-transmission-counters", "receiver-sensitivity", "rssi", "snr", "thread-openthread-version", "transmit-power", "transmit-power-maximum" ] }, "LocalizationKey": "", "ShortUUID": "00000701", "DefaultDescription": "Thread Transport" }, "air-purifier": { "Characteristics": { "Required": ["active", "air-purifier.state.current", "air-purifier.state.target"], "Optional": ["lock-physical-controls", "name", "rotation.speed", "swing-mode"] }, "LocalizationKey": "", "ShortUUID": "000000BB", "DefaultDescription": "Air Purifier" }, "irrigation-system": { "Characteristics": { "Required": ["active", "program-mode", "in-use"], "Optional": ["remaining-duration", "name", "status-fault"] }, "LocalizationKey": "", "ShortUUID": "000000CF", "DefaultDescription": "Irrigation-System" }, "wifi-router": { "Characteristics": { "Required": [ "configured-name", "managed-network-enable", "network-access-violation-control", "network-client-control", "network-client-status-control", "router-status", "supported-router-configuration", "wan-configuration-list", "wan-status-list" ] }, "LocalizationKey": "", "ShortUUID": "0000020A", "DefaultDescription": "Wi-Fi Router" }, "garage-door-opener": { "DefaultDescription": "Garage Door Opener", "Characteristics": { "Required": ["door-state.current", "door-state.target", "obstruction-detected"], "Optional": ["lock-mechanism.current-state", "lock-mechanism.target-state", "name"] }, "ShortUUID": "00000041", "LocalizationKey": "", "BTLE_ShortUUID": "FECE" }, "cloud-relay": { "Characteristics": { "Required": ["cloud-relay.control-point", "cloud-relay.current-state", "cloud-relay.enabled"] }, "LocalizationKey": "", "ShortUUID": "0000005A", "DefaultDescription": "Cloud Relay" }, "diagnostics": { "Characteristics": { "Required": ["supported-diagnostics-snapshot"], "Optional": ["selected-diagnostics-modes", "supported-diagnostics-modes"] }, "LocalizationKey": "", "ShortUUID": "00000237", "DefaultDescription": "Diagnostics" }, "target-control": { "Characteristics": { "Required": ["active", "active-identifier", "button-event"], "Optional": ["name"] }, "LocalizationKey": "", "ShortUUID": "00000125", "DefaultDescription": "Target Control" }, "sensor.leak": { "Characteristics": { "Required": ["leak-detected"], "Optional": ["name", "status-active", "status-fault", "status-lo-batt", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "00000083", "DefaultDescription": "Leak Sensor" }, "asset-update": { "Characteristics": { "Required": ["asset-update-readiness", "supported-asset-types"] }, "LocalizationKey": "", "ShortUUID": "00000267", "DefaultDescription": "Asset Update" }, "sensor.temperature": { "Characteristics": { "Required": ["temperature.current"], "Optional": ["name", "status-active", "status-fault", "status-lo-batt", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "0000008A", "DefaultDescription": "Temperature Sensor" }, "sensor.carbon-monoxide": { "Characteristics": { "Required": ["carbon-monoxide.detected"], "Optional": [ "carbon-monoxide.level", "carbon-monoxide.peak-level", "name", "status-active", "status-fault", "status-lo-batt", "status-tampered" ] }, "LocalizationKey": "", "ShortUUID": "0000007F", "DefaultDescription": "Carbon monoxide Sensor" }, "data-stream-transport-management": { "Characteristics": { "Required": ["setup-data-stream-transport", "supported-data-stream-transport-configuration", "version"] }, "LocalizationKey": "", "ShortUUID": "00000129", "DefaultDescription": "Data Stream Transport Management" }, "sensor.contact": { "AllowAssociatedService": 1, "Characteristics": { "Required": ["contact-state"], "Optional": ["name", "status-active", "status-fault", "status-lo-batt", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "00000080", "DefaultDescription": "Contact Sensor" }, "doorbell": { "Characteristics": { "Required": ["input-event"], "Optional": ["brightness", "mute", "name", "operating-state-response", "volume"] }, "LocalizationKey": "", "ShortUUID": "00000121", "DefaultDescription": "Doorbell" }, "protocol-information": { "Characteristics": { "Required": ["version"] }, "LocalizationKey": "", "ShortUUID": "000000A2", "DefaultDescription": "Protocol Information" }, "window": { "Characteristics": { "Required": ["position.current", "position.state", "position.target"], "Optional": ["name", "obstruction-detected", "position.hold"] }, "LocalizationKey": "", "ShortUUID": "0000008B", "DefaultDescription": "Window" }, "wifi-satellite": { "Characteristics": { "Required": ["wifi-satellite-status"] }, "LocalizationKey": "", "ShortUUID": "0000020F", "DefaultDescription": "Wi-Fi Satellite" }, "pairing": { "DefaultDescription": "Pairing", "Characteristics": { "Required": ["list-pairings", "pair-setup", "pair-verify", "pairing-features"] }, "ShortUUID": "00000055", "LocalizationKey": "", "BTLE_ShortUUID": "FED4" }, "sensor.smoke": { "Characteristics": { "Required": ["smoke-detected"], "Optional": ["name", "status-active", "status-fault", "status-lo-batt", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "00000087", "DefaultDescription": "Smoke Sensor" }, "slats": { "Characteristics": { "Required": ["slat.state.current", "slat.type"], "Optional": ["name", "swing-mode", "tilt.current", "tilt.target"] }, "LocalizationKey": "", "ShortUUID": "000000B9", "DefaultDescription": "Slats" }, "battery": { "Characteristics": { "Required": ["status-lo-batt"], "Optional": ["battery-level", "charging-state", "name"] }, "LocalizationKey": "", "ShortUUID": "00000096", "DefaultDescription": "Battery" }, "thermostat": { "DefaultDescription": "Thermostat", "Characteristics": { "Required": [ "heating-cooling.current", "heating-cooling.target", "temperature.current", "temperature.target", "temperature.units" ], "Optional": [ "name", "relative-humidity.current", "relative-humidity.target", "temperature.cooling-threshold", "temperature.heating-threshold" ] }, "ShortUUID": "0000004A", "LocalizationKey": "", "BTLE_ShortUUID": "FED1" }, "lock-mechanism": { "DefaultDescription": "Lock Mechanism", "Characteristics": { "Required": ["lock-mechanism.current-state", "lock-mechanism.target-state"], "Optional": ["name"] }, "ShortUUID": "00000045", "LocalizationKey": "", "BTLE_ShortUUID": "FED0" }, "microphone": { "Characteristics": { "Required": ["mute"], "Optional": ["volume"] }, "LocalizationKey": "", "ShortUUID": "00000112", "DefaultDescription": "Microphone" }, "target-control-management": { "Characteristics": { "Required": ["supported-target-configuration", "target-list"] }, "LocalizationKey": "", "ShortUUID": "00000122", "DefaultDescription": "Target Control Management" }, "lock-management": { "DefaultDescription": "Lock Management", "Characteristics": { "Required": ["lock-management.control-point", "version"], "Optional": [ "administrator-only-access", "audio-feedback", "door-state.current", "lock-management.auto-secure-timeout", "lock-mechanism.last-known-action", "logs", "motion-detected" ] }, "ShortUUID": "00000044", "LocalizationKey": "", "BTLE_ShortUUID": "FECF" }, "sensor.occupancy": { "Characteristics": { "Required": ["occupancy-detected"], "Optional": ["name", "status-active", "status-fault", "status-lo-batt", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "00000086", "DefaultDescription": "Occupancy Sensor" }, "siri-endpoint": { "Characteristics": { "Required": ["siri-endpoint-session-status", "version"], "Optional": ["active-identifier", "manually-disabled"] }, "LocalizationKey": "", "ShortUUID": "00000253", "DefaultDescription": "Siri Endpoint" }, "siri": { "Characteristics": { "Required": ["siri-input-type"], "Optional": [ "multifunction-button", "siri-enable", "siri-engine-revision", "siri-light-on-use", "siri-listening", "siri-touch-to-use" ] }, "LocalizationKey": "", "ShortUUID": "00000133", "DefaultDescription": "Siri" }, "audio-stream-management": { "Characteristics": { "Required": ["supported-audio-stream-configuration", "selected-audio-stream-configuration"] }, "LocalizationKey": "", "ShortUUID": "00000127", "DefaultDescription": "Audio Stream Management" }, "smart-speaker": { "Characteristics": { "Required": ["media-state.current", "media-state.target"], "Optional": ["airplay-enable", "configured-name", "mute", "name", "volume"] }, "LocalizationKey": "", "ShortUUID": "00000228", "DefaultDescription": "Speaker" }, "faucet": { "Characteristics": { "Required": ["active"], "Optional": ["name", "status-fault"] }, "LocalizationKey": "", "ShortUUID": "000000D7", "DefaultDescription": "Faucet" }, "door": { "Characteristics": { "Required": ["position.current", "position.state", "position.target"], "Optional": ["name", "obstruction-detected", "position.hold"] }, "LocalizationKey": "", "ShortUUID": "00000081", "DefaultDescription": "Door" }, "security-system": { "Characteristics": { "Required": ["security-system-state.current", "security-system-state.target"], "Optional": ["name", "security-system.alarm-type", "status-fault", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "0000007E", "DefaultDescription": "Security System" }, "camera-rtp-stream-management": { "Characteristics": { "Required": [ "selected-stream-configuration", "setup-stream-endpoint", "streaming-status", "supported-audio-stream-configuration", "supported-rtp-configuration", "supported-video-stream-configuration" ], "Optional": ["active"] }, "LocalizationKey": "", "ShortUUID": "00000110", "DefaultDescription": "Camera Stream Management" }, "sensor.air-quality": { "Characteristics": { "Required": ["air-quality"], "Optional": [ "density.no2", "density.ozone", "density.pm10", "density.pm2_5", "density.so2", "density.voc", "name", "status-active", "status-fault", "status-lo-batt", "status-tampered" ] }, "LocalizationKey": "", "ShortUUID": "0000008D", "DefaultDescription": "Air Quality Sensor" }, "television": { "Characteristics": { "Required": ["active", "active-identifier", "configured-name", "remote-key", "sleep-discovery-mode"], "Optional": [ "brightness", "closed-captions", "display-order", "media-state.current", "media-state.target", "name", "picture-mode", "power-mode-selection" ] }, "LocalizationKey": "", "ShortUUID": "000000D8", "DefaultDescription": "Television" }, "transfer-transport-management": { "Characteristics": { "Required": ["supported-transfer-transport-configuration", "setup-transfer-transport"] }, "LocalizationKey": "", "ShortUUID": "00000203", "DefaultDescription": "Transfer Transport Management" }, "heater-cooler": { "Characteristics": { "Required": ["active", "heater-cooler.state.current", "heater-cooler.state.target", "temperature.current"], "Optional": [ "lock-physical-controls", "name", "rotation.speed", "swing-mode", "temperature.cooling-threshold", "temperature.heating-threshold", "temperature.units" ] }, "LocalizationKey": "", "ShortUUID": "000000BC", "DefaultDescription": "Heater-Cooler" }, "accessory-information": { "DefaultDescription": "Accessory Information Service", "Characteristics": { "Required": ["identify", "manufacturer", "model", "name", "serial-number"], "Optional": [ "accessory-flags", "app-matching-identifier", "configured-name", "firmware.revision", "hardware-finish", "hardware.revision", "product-data", "software.revision" ] }, "ShortUUID": "0000003E", "LocalizationKey": "", "BTLE_ShortUUID": "FED3" }, "outlet": { "BTLE_ShortUUID": "FECC", "Characteristics": { "Required": ["on"], "Optional": ["name", "outlet-in-use"] }, "AllowAssociatedService": 1, "ShortUUID": "00000047", "LocalizationKey": "", "DefaultDescription": "Outlet" }, "sensor.humidity": { "Characteristics": { "Required": ["relative-humidity.current"], "Optional": ["name", "status-active", "status-fault", "status-lo-batt", "status-tampered"] }, "LocalizationKey": "", "ShortUUID": "00000082", "DefaultDescription": "Humidity Sensor" }, "fanv2": { "Characteristics": { "Required": ["active"], "Optional": [ "fan.state.current", "fan.state.target", "lock-physical-controls", "name", "rotation.direction", "rotation.speed", "swing-mode" ] }, "LocalizationKey": "", "ShortUUID": "000000B7", "DefaultDescription": "Fan" }, "access-code": { "Characteristics": { "Required": ["access-code-control-point", "access-code-supported-configuration", "configuration-state"] }, "LocalizationKey": "", "ShortUUID": "00000260", "DefaultDescription": "Access Code" }, "lightbulb": { "DefaultDescription": "Lightbulb", "Characteristics": { "Required": ["on"], "Optional": [ "brightness", "characteristic-value-active-transition-count", "characteristic-value-transition-control", "color-temperature", "hue", "name", "saturation", "supported-characteristic-value-transition-configuration" ] }, "ShortUUID": "00000043", "LocalizationKey": "", "BTLE_ShortUUID": "FED2" }, "service-label": { "Characteristics": { "Required": ["service-label-namespace"] }, "LocalizationKey": "", "ShortUUID": "000000CC", "DefaultDescription": "Label" }, "camera-recording-management": { "Characteristics": { "Required": [ "active", "supported-camera-recording-configuration", "supported-video-recording-configuration", "supported-audio-recording-configuration", "selected-camera-recording-configuration" ], "Optional": ["recording-audio-active"] }, "LocalizationKey": "", "ShortUUID": "00000204", "DefaultDescription": "Camera Recording Management" }, "switch": { "BTLE_ShortUUID": "FECD", "Characteristics": { "Required": ["on"], "Optional": ["name"] }, "AllowAssociatedService": 1, "ShortUUID": "00000049", "LocalizationKey": "", "DefaultDescription": "Switch" }, "access-control": { "Characteristics": { "Required": ["privilege"], "Optional": ["password-setting"] }, "LocalizationKey": "", "ShortUUID": "000000DA", "DefaultDescription": "Access Control" }, "power-management": { "Characteristics": { "Required": ["wake-configuration"], "Optional": [] }, "LocalizationKey": "", "ShortUUID": "00000221", "DefaultDescription": "Power Management" }, "wifi-transport": { "Characteristics": { "Required": ["current-transport", "wifi-capabilities"], "Optional": ["wifi-configuration-control"] }, "LocalizationKey": "", "ShortUUID": "0000022A", "DefaultDescription": "Wi-Fi Transport" }, "window-covering": { "Characteristics": { "Required": ["position.current", "position.state", "position.target"], "Optional": [ "horizontal-tilt.current", "horizontal-tilt.target", "name", "obstruction-detected", "position.hold", "vertical-tilt.current", "vertical-tilt.target" ] }, "LocalizationKey": "", "ShortUUID": "0000008C", "DefaultDescription": "Window Covering" } } }, "Version": 880, "SchemaVersion": 1, "Assistant": { "Characteristics": { "CONTROL_LOCK": { "Format": "int", "ReadWrite": "lock-physical-controls" }, "HEATING_COOLING_MODE": { "Read": "heating-cooling.current", "Values": { "COOL": 2, "AUTO": 3, "HEAT": 1, "OFF": 0 }, "Format": "string", "Write": "heating-cooling.target" }, "OUTLET_IN_USE": { "Format": "bool", "Read": "outlet-in-use" }, "HEATING_THRESHOLD": { "Format": "float", "SupportsLocalization": 1, "ReadWrite": "temperature.heating-threshold" }, "CARBON_MONOXIDE_PEAK_LEVEL": { "Format": "float", "Read": "carbon-monoxide.peak-level" }, "COOLING_THRESHOLD": { "Format": "float", "SupportsLocalization": 1, "ReadWrite": "temperature.cooling-threshold" }, "HEATER_COOLER_MODE": { "OutValues": { "3": "COOLING", "1": "IDLE", "2": "HEATING", "0": "INACTIVE" }, "Read": "heater-cooler.state.current", "Format": "string", "Values": { "AUTO": 0, "HEAT_AUTO": 1, "COOL_AUTO": 2 }, "Write": "heater-cooler.state.target" }, "PROGRAM_MODE": { "Format": "int", "Read": "program-mode" }, "FILTER_CHANGE": { "Values": { "CHANGE": 1, "NO_CHANGE": 0 }, "Format": "string", "Read": "filter.change-indication" }, "AIR_PARTICULATE_DENSITY": { "Format": "float", "Read": "air-particulate.density" }, "TILT": { "Write": "tilt.target", "Format": "int", "Read": "tilt.current" }, "DURATION": { "Format": "int", "ReadWrite": "set-duration" }, "SATURATION": { "Format": "float", "ReadWrite": "saturation" }, "CARBON_DIOXIDE_DETECTED": { "Values": { "ABNORMAL": 1, "NORMAL": 0 }, "Format": "string", "Read": "carbon-dioxide.detected" }, "AMBIENT_LIGHT_LEVEL": { "Format": "float", "Read": "light-level.current" }, "CARBON_DIOXIDE_LEVEL": { "Format": "float", "Read": "carbon-dioxide.level" }, "CARBON_MONOXIDE_DETECTED": { "Format": "bool", "Read": "carbon-monoxide.detected" }, "IN_USE": { "Format": "int", "Read": "in-use" }, "IDENTIFY": { "Write": "identify", "Format": "bool" }, "ROTATION_SPEED": { "Format": "float", "ReadWrite": "rotation.speed" }, "HUMIDIFIER_THRESHOLD": { "Format": "float", "ReadWrite": "relative-humidity.humidifier-threshold" }, "NITROGEN_DIOXIDE_DENSITY": { "Format": "float", "Read": "density.no2" }, "REMAINING_DURATION": { "Format": "int", "Read": "remaining-duration" }, "CONTACT_DETECTED": { "Values": { "0": "0", "1": "1" }, "Format": "int", "Read": "contact-state" }, "HUMIDIFIER_DEHUMIDIFIER_MODE": { "OutValues": { "3": "DEHUMIDIFYING", "1": "IDLE", "2": "HUMIDIFYING", "0": "INACTIVE" }, "Read": "humidifier-dehumidifier.state.current", "Format": "string", "Values": { "AUTO": 0, "HUMIDIFY_AUTO": 1, "DEHUMIDIFY_AUTO": 2 }, "Write": "humidifier-dehumidifier.state.target" }, "SLAT_OPERATING_MODE": { "OutValues": { "3": "JAMMED", "1": "FIXED", "2": "SWINGING", "0": "INACTIVE" }, "Read": "slat.state.current", "Format": "string", "Values": { "AUTO": 1, "MANUAL": 0 } }, "BRIGHTNESS": { "Format": "int", "ReadWrite": "brightness" }, "FAN_OPERATING_MODE": { "OutValues": { "0": "INACTIVE", "1": "IDLE", "2": "BLOWING" }, "Read": "fan.state.current", "Format": "string", "Values": { "AUTO": 1, "MANUAL": 0 }, "Write": "fan.state.target" }, "CARBON_DIOXIDE_PEAK_LEVEL": { "Format": "float", "Read": "carbon-dioxide.peak-level" }, "ROTATION_DIRECTION": { "Values": { "COUNTERCLOCKWISE": 1, "CLOCKWISE": 0 }, "Format": "string", "ReadWrite": "rotation.direction" }, "AIR_PURIFIER_OPERATING_MODE": { "OutValues": { "0": "INACTIVE", "1": "IDLE", "2": "PURIFYING_AIR" }, "Read": "air-purifier.state.current", "Format": "string", "Values": { "AUTO": 1, "MANUAL": 0 }, "Write": "air-purifier.state.target" }, "OCCUPANCY_DETECTED": { "Values": { "OCCUPANCY_DETECTED": 1, "OCCUPANCY_NOT_DETECTED": 0 }, "Format": "string", "Read": "occupancy-detected" }, "DEHUMIDIFIER_THRESHOLD": { "Format": "float", "ReadWrite": "relative-humidity.dehumidifier-threshold" }, "SMOKE_DETECTED": { "Format": "bool", "Read": "smoke-detected" }, "TEMPERATURE": { "Read": "temperature.current", "SupportsLocalization": 1, "Format": "float", "Write": "temperature.target" }, "POSITION": { "Write": "position.target", "Format": "int", "Read": "position.current" }, "RAISE": { "OutValues": { "3": 3, "1": 0, "4": 4, "2": 2, "0": 1 }, "Read": "door-state.current", "Format": "int", "Values": { "0": 1, "1": 0 }, "Write": "door-state.target" }, "LOCK": { "Read": "lock-mechanism.current-state", "Values": { "0": 0, "1": 1 }, "Format": "int", "Write": "lock-mechanism.target-state" }, "LOW_BATTERY": { "Values": { "BATTERY_NORMAL": 0, "BATTERY_LOW": 1 }, "Format": "string", "Read": "status-lo-batt" }, "HUMIDITY": { "Write": "relative-humidity.target", "Format": "float", "Read": "relative-humidity.current" }, "HUE": { "Format": "float", "ReadWrite": "hue" }, "MOTION_DETECTED": { "Format": "bool", "Read": "motion-detected" }, "SECURITY_SYSTEM_STATE": { "Read": "security-system-state.current", "Values": { "DISARM": 3, "ALARM_TRIGGERED": 4, "NIGHT_ARM": 2, "AWAY_ARM": 1, "STAY_ARM": 0 }, "Format": "string", "Write": "security-system-state.target" }, "PARTICULATE_MATTER_2_5_DENSITY": { "Format": "float", "Read": "density.pm2_5" }, "FILTER_LIFE": { "Format": "float", "ReadWrite": "filter.life-level" }, "VOLATILE_ORGANIC_COMPOUND_DENSITY": { "Format": "float", "Read": "density.voc" }, "CHARGING_STATE": { "Values": { "NOT_CHARGEABLE": 2, "CHARGING": 1, "NOT_CHARGING": 0 }, "Format": "string", "Read": "charging-state" }, "CARBON_MONOXIDE_LEVEL": { "Format": "float", "Read": "carbon-monoxide.level" }, "PARTICULATE_MATTER_10_DENSITY": { "Format": "float", "Read": "density.pm10" }, "LEAK_DETECTED": { "Values": { "LEAK_NOT_DETECTED": 0, "LEAK_DETECTED": 1 }, "Format": "string", "Read": "leak-detected" }, "OZONE_DENSITY": { "Format": "float", "Read": "density.ozone" }, "AIR_QUALITY_RATING": { "Values": { "GOOD": 2, "POOR": 5, "INFERIOR": 4, "EXCELLENT": 1, "FAIR": 3, "UNKNOWN": 0 }, "Format": "string", "Read": "air-quality" }, "OBSTRUCTION_DETECTED": { "Format": "bool", "Read": "obstruction-detected" }, "SWING_MODE": { "Format": "bool", "ReadWrite": "swing-mode" }, "POWER": { "Format": "bool", "ReadWrite": "on" }, "BATTERY_LEVEL": { "Format": "int", "Read": "battery-level" }, "SULPHUR_DIOXIDE_DENSITY": { "Format": "float", "Read": "density.so2" }, "WATER_LEVEL": { "Format": "float", "Read": "water-level" } }, "Services": { "LEAK_SENSOR": "sensor.leak", "TELEVISION": "television", "AIR_QUALITY_SENSOR": "sensor.air-quality", "HEATER_COOLER": "heater-cooler", "LIGHTBULB": "lightbulb", "HUMIDIFIER_DEHUMIDIFIER": "humidifier-dehumidifier", "HUMIDITY_SENSOR": "sensor.humidity", "LIGHT_SENSOR": "sensor.light", "CARBON_DIOXIDE_SENSOR": "sensor.carbon-dioxide", "OUTLET": "outlet", "FAUCET": "faucet", "GARAGE_DOOR_OPENER": "garage-door-opener", "SHADES": "window-covering", "AIR_PURIFIER": "air-purifier", "SLAT": "slats", "SWITCH": "switch", "IRRIGATION_SYSTEM": "irrigation-system", "CARBON_MONOXIDE_SENSOR": "sensor.carbon-monoxide", "DOOR_LOCK": "lock-mechanism", "SECURITY_SYSTEM": "security-system", "MOTORIZED_WINDOW": "window", "TEMPERATURE_SENSOR": "sensor.temperature", "BATTERY_SERVICE": "battery", "CONTACT_SENSOR": "sensor.contact", "FILTER_MAINTENANCE": "filter-maintenance", "VALVE": "valve", "MOTION_SENSOR": "sensor.motion", "VENTILATION_FAN": "fan", "OCCUPANCY_SENSOR": "sensor.occupancy", "SMOKE_SENSOR": "sensor.smoke", "THERMOSTAT": "thermostat", "MOTORIZED_DOOR": "door" }, "Units": { "PERCENT": "percentage", "CELSIUS": "celsius", "FAHRENHEIT": "fahrenheit", "ARC_DEGREES": "arcdegrees", "LUX": "lux", "SECONDS": "seconds" } } }, "SchemaVersion": 1 } ================================================ FILE: codegen/src/main.rs ================================================ use handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError, Renderable}; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; use std::{ collections::HashMap, fs::{self, File}, io::Write, }; #[derive(Debug, Clone, Serialize, Deserialize)] struct SystemMetadata { #[serde(rename = "Version")] pub version: usize, #[serde(rename = "SchemaVersion")] pub schema_version: usize, #[serde(rename = "PlistDictionary")] pub plist_dictionary: SystemPlistDictionary, } #[derive(Debug, Clone, Serialize, Deserialize)] struct SystemPlistDictionary { #[serde(rename = "Version")] pub version: usize, #[serde(rename = "SchemaVersion")] pub schema_version: usize, #[serde(rename = "HomeKit")] pub homekit: HomeKit, #[serde(rename = "HAP")] pub hap: Hap, #[serde(rename = "Assistant")] pub assistant: Assistant, } #[derive(Debug, Clone, Serialize, Deserialize)] struct HomeKit { #[serde(rename = "Categories")] pub categories: HashMap, } #[derive(Debug, Clone, Serialize, Deserialize)] struct HomeKitCategory { #[serde(rename = "DefaultDescription")] pub name: String, #[serde(rename = "Identifier")] pub number: u8, #[serde(rename = "UUID")] pub uuid: String, } #[derive(Debug, Clone, Serialize, Deserialize)] struct Hap { #[serde(rename = "Base UUID")] pub base_uuid: String, #[serde(rename = "Characteristics")] pub characteristics: HashMap, #[serde(rename = "Services")] pub services: HashMap, #[serde(rename = "Properties")] pub properties: HashMap, } #[derive(Debug, Clone, Serialize, Deserialize)] struct HapCharacteristic { #[serde(rename = "ShortUUID")] pub short_uuid: String, #[serde(rename = "DefaultDescription")] pub name: String, #[serde(rename = "Format")] pub format: String, #[serde(rename = "MinValue")] pub min_value: Option, #[serde(rename = "MaxValue")] pub max_value: Option, #[serde(rename = "StepValue")] pub step_value: Option, #[serde(rename = "MaxLength")] pub max_length: Option, #[serde(rename = "Units")] pub units: Option, #[serde(rename = "Properties")] pub properties: usize, } #[derive(Debug, Clone, Serialize, Deserialize)] struct HapService { #[serde(rename = "ShortUUID")] pub short_uuid: String, #[serde(rename = "DefaultDescription")] pub name: String, #[serde(rename = "Characteristics")] pub characteristics: HapServiceCharacteristicRelation, } #[derive(Debug, Clone, Serialize, Deserialize)] struct HapServiceCharacteristicRelation { #[serde(rename = "Required")] pub required_characteristics: Vec, #[serde(rename = "Optional")] pub optional_characteristics: Option>, } #[derive(Debug, Clone, Serialize, Deserialize)] struct HapProperty { #[serde(rename = "DefaultDescription")] pub name: String, #[serde(rename = "Position")] pub number: u8, } #[derive(Debug, Clone, Serialize, Deserialize)] struct Assistant { #[serde(rename = "Characteristics")] pub characteristics: HashMap, } #[derive(Debug, Clone, Serialize, Deserialize)] struct AssistantCharacteristic { #[serde(rename = "Format")] pub format: String, #[serde(rename = "Read")] pub read: Option, #[serde(rename = "Write")] pub write: Option, #[serde(rename = "ReadWrite")] pub read_write: Option, #[serde(rename = "Values")] pub values: Option>, #[serde(rename = "OutValues")] pub out_values: Option>, } #[derive(Debug, Clone, Serialize, Deserialize)] struct RenderMetadata { pub categories: HashMap, pub sorted_categories: Vec, pub characteristics: HashMap, pub sorted_characteristics: Vec, pub services: HashMap, pub sorted_services: Vec, pub properties: HashMap, pub assistant_characteristics: HashMap, pub characteristic_in_values: HashMap>, pub characteristic_out_values: HashMap>, } impl From for RenderMetadata { fn from(v: SystemMetadata) -> Self { let mut m = v.plist_dictionary; // rename mislabeled services let mut accessory_information_service = m.hap.services.get_mut("accessory-information").unwrap(); accessory_information_service.name = "Accessory Information".to_string(); let mut fan_v2_service = m.hap.services.get_mut("fanv2").unwrap(); fan_v2_service.name = "Fan v2".to_string(); let mut smart_speaker_service = m.hap.services.get_mut("smart-speaker").unwrap(); smart_speaker_service.name = "Smart Speaker".to_string(); let mut sorted_categories = m.homekit.categories.iter().map(|(_, v)| v.clone()).collect::>(); sorted_categories.sort_by(|a, b| a.number.partial_cmp(&b.number).unwrap()); let mut sorted_characteristics = m.hap.characteristics.iter().map(|(_, v)| v.clone()).collect::>(); sorted_characteristics.sort_by(|a, b| a.name.cmp(&b.name)); let mut sorted_services = m.hap.services.iter().map(|(_, v)| v.clone()).collect::>(); sorted_services.sort_by(|a, b| a.name.cmp(&b.name)); let mut characteristic_in_values = HashMap::new(); let mut characteristic_out_values = HashMap::new(); for (_, characteristic) in m.assistant.characteristics.clone() { if let (Some(ref read_name), Some(ref values), &None) = (&characteristic.read, &characteristic.values, &characteristic.out_values) { characteristic_in_values.insert(read_name.clone(), values.clone()); } if let (Some(ref read_write_name), Some(ref values), &None) = ( &characteristic.read_write, &characteristic.values, &characteristic.out_values, ) { characteristic_in_values.insert(read_write_name.clone(), values.clone()); } if let (Some(read_name), Some(out_values)) = (characteristic.read, characteristic.out_values) { characteristic_out_values.insert(read_name, out_values); } if let (Some(write_name), Some(values)) = (characteristic.write, characteristic.values) { characteristic_in_values.insert(write_name, values); } } Self { categories: m.homekit.categories, sorted_categories, characteristics: m.hap.characteristics, sorted_characteristics, services: m.hap.services, sorted_services, properties: m.hap.properties, assistant_characteristics: m.assistant.characteristics, characteristic_in_values, characteristic_out_values, } } } fn if_eq_helper<'reg, 'rc>( h: &Helper<'reg, 'rc>, r: &'reg Handlebars, c: &Context, rc: &mut RenderContext<'reg>, out: &mut dyn Output, ) -> Result<(), RenderError> { let first = h.param(0).unwrap().value(); let second = h.param(1).unwrap().value(); let tmpl = if first == second { h.template() } else { h.inverse() }; match tmpl { Some(ref t) => t.render(r, c, rc, out), None => Ok(()), } } fn trim_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value(); if let Some(s) = param.as_str() { let trim = s.replace(" ", "").replace(".", "_"); out.write(&trim)?; } Ok(()) } fn file_name_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value(); if let Some(s) = param.as_str() { let name = s.replace(" ", "_").replace(".", "_").to_lowercase(); out.write(&name)?; } Ok(()) } fn type_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value(); if let Some(s) = param.as_str() { match s { "bool" => { out.write("bool")?; }, "uint8" => { out.write("u8")?; }, "uint16" => { out.write("u16")?; }, "uint32" => { out.write("u32")?; }, "uint64" => { out.write("u64")?; }, "int" => { out.write("i32")?; }, "int32" => { out.write("i32")?; }, "float" => { out.write("f32")?; }, "string" => { out.write("String")?; }, "tlv8" => { out.write("Vec")?; }, "data" => { out.write("Vec")?; }, _ => { return Err(RenderError::new("Unknown Characteristic format")); }, } } Ok(()) } fn format_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value(); if let Some(s) = param.as_str() { match s { "bool" => { out.write("Format::Bool")?; }, "uint8" => { out.write("Format::UInt8")?; }, "uint16" => { out.write("Format::UInt16")?; }, "uint32" => { out.write("Format::UInt32")?; }, "uint64" => { out.write("Format::UInt64")?; }, "int" => { out.write("Format::Int32")?; }, "int32" => { out.write("Format::Int32")?; }, "float" => { out.write("Format::Float")?; }, "string" => { out.write("Format::String")?; }, "tlv8" => { out.write("Format::Tlv8")?; }, "data" => { out.write("Format::Data")?; }, _ => { return Err(RenderError::new("Unknown Characteristic format")); }, } } Ok(()) } fn unit_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value(); if let Some(s) = param.as_str() { match s { "celsius" => { out.write("Unit::Celsius")?; }, "fahrenheit" => { out.write("Unit::Celsius")?; }, "percentage" => { out.write("Unit::Percentage")?; }, "arcdegrees" => { out.write("Unit::ArcDegrees")?; }, "lux" => { out.write("Unit::Lux")?; }, "seconds" => { out.write("Unit::Seconds")?; }, "ppm" => { out.write("Unit::PartsPerMillion")?; }, "micrograms/m^3" => { out.write("Unit::MicrogramsPerCubicMeter")?; }, _ => { return Err(RenderError::new("Unknown Characteristic unit")); }, } } Ok(()) } fn category_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value().as_str().unwrap(); match param.to_lowercase().as_str() { "air quality sensor" | "carbon dioxide sensor" | "carbon monoxide sensor" | "contact sensor" | "humidity sensor" | "leak sensor" | "light sensor" | "motion sensor" | "occupancy sensor" | "smoke sensor" | "temperature sensor" => { out.write("AccessoryCategory::Sensor")?; }, "doorbell" => { out.write("AccessoryCategory::VideoDoorbell")?; }, "fan v2" => { out.write("AccessoryCategory::Fan")?; }, "heater-cooler" => { out.write("AccessoryCategory::AirHeater /* or AccessoryCategory::AirConditioner */")?; }, "humidifier-dehumidifier" => { out.write("AccessoryCategory::AirHumidifier /* or AccessoryCategory::AirDehumidifier */")?; }, "irrigation-system" => { out.write("AccessoryCategory::Sprinkler")?; }, "smart speaker" => { out.write("AccessoryCategory::Speaker")?; }, "stateful programmable switch" | "stateless programmable switch" => { out.write("AccessoryCategory::ProgrammableSwitch")?; }, "wi-fi satellite" => { out.write("AccessoryCategory::WiFiRouter")?; }, _ => { let param = param.replace("-", " "); let name = param .to_lowercase() .split(" ") .into_iter() .map(|word| { let mut c = word.chars().collect::>(); c[0] = c[0].to_uppercase().nth(0).unwrap(); c.into_iter().collect::() }) .collect::(); let name = name.replace(" ", "").replace(".", "_"); out.write(&format!("AccessoryCategory::{}", name))?; }, } Ok(()) } fn uuid_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value(); if let Some(s) = param.as_str() { out.write(&shorten_uuid(&s))?; } Ok(()) } fn in_values_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value().as_object().unwrap(); let mut values = param .into_iter() .map(|(key, val)| (key.clone(), val.clone().to_string().replace("\"", ""))) .collect::>(); values.sort_by(|a, b| a.1.cmp(&b.1)); let mut output = String::from("vec![\n"); for (key, val) in values { output.push_str(&format!("\t\t\t\t{}, // {}\n", val, key)); } output.push_str("\t\t\t]"); out.write(&output)?; Ok(()) } fn out_values_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value().as_object().unwrap(); let mut values = param .into_iter() .map(|(key, val)| (val.clone().to_string().replace("\"", ""), key.clone())) .collect::>(); values.sort_by(|a, b| a.1.cmp(&b.1)); let mut output = String::from("vec![\n"); for (key, val) in values { output.push_str(&format!("\t\t\t\t{}, // {}\n", val, key)); } output.push_str("\t\t\t]"); out.write(&output)?; Ok(()) } fn in_values_enum_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value().as_object().unwrap(); let mut values = param .into_iter() .map(|(key, val)| (key.clone(), val.clone().to_string().replace("\"", ""))) .collect::>(); values.sort_by(|a, b| a.1.cmp(&b.1)); let mut output = String::from("\npub enum Value {\n"); for (key, val) in values { let key = key .to_lowercase() .split("_") .into_iter() .map(|word| { let mut c = word.chars().collect::>(); if c.len() == 1 && c[0].is_numeric() { format!("Num{}", c[0]) } else { c[0] = c[0].to_uppercase().nth(0).unwrap(); c.into_iter().collect::() } }) .collect::(); output.push_str(&format!("\t{} = {},\n", key, val)); } output.push_str("}\n"); out.write(&output)?; Ok(()) } fn out_values_enum_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value().as_object().unwrap(); let mut values = param .into_iter() .map(|(key, val)| (val.clone().to_string().replace("\"", ""), key.clone())) .collect::>(); values.sort_by(|a, b| a.1.cmp(&b.1)); let mut output = String::from("\npub enum Value {\n"); for (key, val) in values { let key = key .to_lowercase() .split("_") .into_iter() .map(|word| { let mut c = word.chars().collect::>(); if c.len() == 1 && c[0].is_numeric() { format!("Num{}", c[0]) } else { c[0] = c[0].to_uppercase().nth(0).unwrap(); c.into_iter().collect::() } }) .collect::(); output.push_str(&format!("\t{} = {},\n", key, val)); } output.push_str("}\n"); out.write(&output)?; Ok(()) } fn perms_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let perms = vec![ (1 << 0, "\n\t\t\t\tPerm::Events,".to_string()), (1 << 1, "\n\t\t\t\tPerm::PairedRead,".to_string()), (1 << 2, "\n\t\t\t\tPerm::PairedWrite,".to_string()), // Relevant for Bluetooth. // (1 << 3, "\n\t\t\t\tPerm::Broadcast,".to_string()), // aa set by homed just signals that aa may be supported. Setting up aa will always require a custom made app // though. (1 << 4, "\n\t\t\t\tPerm::AdditionalAuthorization,".to_string()), (1 << 5, "\n\t\t\t\tPerm::TimedWrite,".to_string()), (1 << 6, "\n\t\t\t\tPerm::Hidden,".to_string()), (1 << 7, "\n\t\t\t\tPerm::WriteResponse,".to_string()), ]; let properties_bitmap = h.param(0).unwrap().value().as_u64().unwrap(); for (bitmap, name) in perms { // if it stays the same, the bit is set if (bitmap | properties_bitmap) == properties_bitmap { out.write(&name)?; } } Ok(()) } fn float_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let format = h.param(0).unwrap().value().as_str().unwrap(); if format == "float" { out.write(" as f32")?; } Ok(()) } fn array_length_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let array = h.param(0).unwrap().value().as_array().unwrap(); out.write(&format!("{}", array.len()))?; Ok(()) } fn shorten_uuid(id: &str) -> String { id.trim_start_matches('0').to_owned() } fn snake_case_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value().as_str().unwrap(); let name = param .replace(" ", "_") .replace(".", "_") .replace("-", "_") .to_lowercase(); out.write(&name)?; Ok(()) } fn pascal_case_helper( h: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> Result<(), RenderError> { let param = h.param(0).unwrap().value().as_str().unwrap().to_owned(); let param = param.replace("-", " "); let name = param .to_lowercase() .split(" ") .into_iter() .map(|word| { let mut c = word.chars().collect::>(); c[0] = c[0].to_uppercase().nth(0).unwrap(); c.into_iter().collect::() }) .collect::(); let name = name.replace(" ", "").replace(".", "_"); out.write(&name)?; Ok(()) } static CATEGORIES: &'static str = "// this file is auto-generated by hap-codegen\n use serde::{Deserialize, Serialize}; /// HAP accessory category. #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] pub enum AccessoryCategory { {{#each sorted_categories as |c|}}\ \t{{pascal_case c.DefaultDescription}} = {{c.Identifier}}, {{/each}}\ } "; static HAP_TYPE: &'static str = "// this file is auto-generated by hap-codegen\n use serde::{ de::{self, Deserialize, Deserializer}, ser::{Serialize, Serializer}, }; use std::str::FromStr; use uuid::Uuid; use crate::Error; /// HAP service and characteristic type representation. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum HapType { Unknown, Custom(Uuid), {{#each sorted_characteristics as |c|}}\ \t{{pascal_case c.DefaultDescription}}, {{/each}}\ {{#each sorted_services as |s|}}\ \t{{pascal_case s.DefaultDescription}}, {{/each}}\ } impl ToString for HapType { fn to_string(&self) -> String { match self { HapType::Unknown => \"unknown\".into(), HapType::Custom(uuid) => uuid.to_hyphenated().to_string(), {{#each sorted_characteristics as |c|}}\ \t\t\tHapType::{{pascal_case c.DefaultDescription}} => \"{{uuid c.ShortUUID}}\".into(), {{/each}}\ {{#each sorted_services as |s|}}\ \t\t\tHapType::{{pascal_case s.DefaultDescription}} => \"{{uuid s.ShortUUID}}\".into(), {{/each}}\ \t\t} } } impl FromStr for HapType { type Err = Error; fn from_str(s: &str) -> Result { if let Ok(uuid) = Uuid::parse_str(s) { return Ok(HapType::Custom(uuid)); } match s { \"unknown\" => Ok(HapType::Unknown), {{#each sorted_characteristics as |c|}}\ \t\t\t\"{{uuid c.ShortUUID}}\" => Ok(HapType::{{pascal_case c.DefaultDescription}}), {{/each}}\ {{#each sorted_services as |s|}}\ \t\t\t\"{{uuid s.ShortUUID}}\" => Ok(HapType::{{pascal_case s.DefaultDescription}}), {{/each}}\ \t\t\t_ => Err(Error::InvalidHapTypeString(s.to_string())), \t\t} } } impl Default for HapType { fn default() -> HapType { HapType::Unknown } } impl<'de> Deserialize<'de> for HapType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let s = String::deserialize(deserializer)?; let hap_type = HapType::from_str(&s).map_err(de::Error::custom)?; Ok(hap_type) } } impl Serialize for HapType { fn serialize(&self, serializer: S) -> Result { serializer.serialize_str(&self.to_string()) } } "; static CHARACTERISTIC: &'static str = "// this file is auto-generated by hap-codegen\n use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// {{characteristic.DefaultDescription}} characteristic. #[derive(Debug, Default, Serialize)] pub struct {{pascal_case characteristic.DefaultDescription}}Characteristic(Characteristic<{{type characteristic.Format}}>); {{#if in_values includeZero=true}}{{in_values_enum in_values}}{{/if}}{{#if out_values includeZero=true}}{{out_values_enum out_values}}{{/if}} impl {{pascal_case characteristic.DefaultDescription}}Characteristic { /// Creates a new {{characteristic.DefaultDescription}} characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::<{{type characteristic.Format}}> { id, accessory_id, hap_type: HapType::{{pascal_case characteristic.DefaultDescription}}, format: {{format characteristic.Format}}, perms: vec![{{perms characteristic.Properties}} ],\ {{#if characteristic.Units}}\n\t\t\tunit: Some({{unit characteristic.Units}}),{{/if}}\ {{#if characteristic.MaxValue includeZero=true}}\n\t\t\tmax_value: Some({{characteristic.MaxValue}}{{float characteristic.Format}}),{{/if}}\ {{#if characteristic.MinValue includeZero=true}}\n\t\t\tmin_value: Some({{characteristic.MinValue}}{{float characteristic.Format}}),{{/if}}\ {{#if characteristic.StepValue includeZero=true}}\n\t\t\tstep_value: Some({{characteristic.StepValue}}{{float characteristic.Format}}),{{/if}}\ {{#if characteristic.MaxLength includeZero=true}}\n\t\t\tmax_len: Some({{characteristic.MaxLength}}{{float characteristic.Format}}),{{/if}}\ {{#if in_values includeZero=true}}\n\t\t\tvalid_values: Some({{in_values in_values}}),{{/if}}{{#if out_values includeZero=true}}\n\t\t\tvalid_values: Some({{out_values out_values}}),{{/if}} ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for {{pascal_case characteristic.DefaultDescription}}Characteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for {{pascal_case characteristic.DefaultDescription}}Characteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks<{{type characteristic.Format}}> for {{pascal_case characteristic.DefaultDescription}}Characteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks<{{type characteristic.Format}}> for {{pascal_case characteristic.DefaultDescription}}Characteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } "; static CHARACTERISTIC_MOD: &'static str = "// this file is auto-generated by hap-codegen {{#each characteristics as |c|}}\n/// {{c.name}} characteristic definition.\npub mod {{c.file_name}};{{/each}} "; static SERVICE: &'static str = "// this file is auto-generated by hap-codegen\n use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, {{#each required_characteristics as |r|}}\ \t\t{{snake_case r.DefaultDescription}}::{{pascal_case r.DefaultDescription}}Characteristic, {{/each}}\ {{#each optional_characteristics as |r|}}\ \t\t{{snake_case r.DefaultDescription}}::{{pascal_case r.DefaultDescription}}Characteristic, {{/each}}\ \t}, HapType, }; /// {{service.DefaultDescription}} service. #[derive(Debug, Default)] pub struct {{pascal_case service.DefaultDescription}}Service { /// Instance ID of the {{service.DefaultDescription}} service. id: u64, /// [`HapType`](HapType) of the {{service.DefaultDescription}} service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, {{#each required_characteristics as |r|}}\ \t/// {{r.DefaultDescription}} characteristic (required). \tpub {{snake_case r.DefaultDescription}}: {{pascal_case r.DefaultDescription}}Characteristic, {{/each}}\ \n{{#each optional_characteristics as |o|}}\ \t/// {{o.DefaultDescription}} characteristic (optional). \tpub {{snake_case o.DefaultDescription}}: Option<{{pascal_case o.DefaultDescription}}Characteristic>, {{/each}}\ } impl {{pascal_case service.DefaultDescription}}Service { /// Creates a new {{service.DefaultDescription}} service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::{{pascal_case service.DefaultDescription}}, {{#each required_characteristics as |r|}}\ \t\t\t{{snake_case r.DefaultDescription}}: {{pascal_case r.DefaultDescription}}Characteristic::new(id + 1 + {{@index}}, accessory_id), {{/each}}\ {{#each optional_characteristics as |o|}}\ \t\t\t{{snake_case o.DefaultDescription}}: Some({{pascal_case o.DefaultDescription}}Characteristic::new(id + 1 + {{@index}} + {{array_length ../required_characteristics}}, accessory_id)), {{/each}}\ \t\t\t..Default::default() } } } impl HapService for {{pascal_case service.DefaultDescription}}Service { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ {{#each required_characteristics as |r|}}\ \t\t\t&self.{{snake_case r.DefaultDescription}}, {{/each}}\ \t\t]; {{#each optional_characteristics as |r|}}\ \t\tif let Some(c) = &self.{{snake_case r.DefaultDescription}} { \t\t characteristics.push(c); \t\t} {{/each}}\ \t\tcharacteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ {{#each required_characteristics as |r|}}\ \t\t\t&mut self.{{snake_case r.DefaultDescription}}, {{/each}}\ \t\t]; {{#each optional_characteristics as |r|}}\ \t\tif let Some(c) = &mut self.{{snake_case r.DefaultDescription}} { \t\t characteristics.push(c); \t\t} {{/each}}\ \t\tcharacteristics } } impl Serialize for {{pascal_case service.DefaultDescription}}Service { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct(\"HapService\", 5)?; state.serialize_field(\"iid\", &self.get_id())?; state.serialize_field(\"type\", &self.get_type())?; state.serialize_field(\"hidden\", &self.get_hidden())?; state.serialize_field(\"primary\", &self.get_primary())?; state.serialize_field(\"characteristics\", &self.get_characteristics())?; // linked services left out for now state.end() } } "; static SERVICE_MOD: &'static str = "// this file is auto-generated by hap-codegen {{#each services as |s|}}\n/// {{s.name}} service definition.\npub mod {{s.file_name}};{{/each}} "; static ACCESSORY: &'static str = "// this file is auto-generated by hap-codegen\n use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ \taccessory::{AccessoryInformation, HapAccessory}, \tservice::{HapService, accessory_information::AccessoryInformationService, {{snake_case service.DefaultDescription}}::{{pascal_case service.DefaultDescription}}Service}, \tHapType, \tResult, }; /// {{service.DefaultDescription}} accessory. #[derive(Debug, Default)] pub struct {{pascal_case service.DefaultDescription}}Accessory { /// ID of the {{service.DefaultDescription}} accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// {{service.DefaultDescription}} service. pub {{snake_case service.DefaultDescription}}: {{pascal_case service.DefaultDescription}}Service, } impl {{pascal_case service.DefaultDescription}}Accessory { /// Creates a new {{service.DefaultDescription}} accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let {{snake_case service.DefaultDescription}}_id = accessory_information.get_characteristics().len() as u64; let mut {{snake_case service.DefaultDescription}} = {{pascal_case service.DefaultDescription}}Service::new(1 + {{snake_case service.DefaultDescription}}_id + 1, id); {{snake_case service.DefaultDescription}}.set_primary(true); Ok(Self { id, accessory_information, {{snake_case service.DefaultDescription}}, }) } } impl HapAccessory for {{pascal_case service.DefaultDescription}}Accessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.{{snake_case service.DefaultDescription}}, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.{{snake_case service.DefaultDescription}}, ] } } impl Serialize for {{pascal_case service.DefaultDescription}}Accessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct(\"HapAccessory\", 2)?; state.serialize_field(\"aid\", &self.get_id())?; state.serialize_field(\"services\", &self.get_services())?; state.end() } } "; static ACCESSORY_MOD: &'static str = "// this file is auto-generated by hap-codegen {{#each accessories as |a|}}\n/// {{a.name}} accessory definition.\npub mod {{a.file_name}};{{/each}} "; static EXAMPLE: &'static str = "\ use tokio; use hap::{ accessory::{AccessoryCategory, AccessoryInformation, {{snake_case service.DefaultDescription}}::{{pascal_case service.DefaultDescription}}Accessory}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let {{snake_case service.DefaultDescription}} = {{pascal_case service.DefaultDescription}}Accessory::new(1, AccessoryInformation { name: \"Acme {{service.DefaultDescription}}\".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: \"Acme {{service.DefaultDescription}}\".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: {{category service.DefaultDescription}}, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory({{snake_case service.DefaultDescription}}).await?; let handle = server.run_handle(); std::env::set_var(\"RUST_LOG\", \"hap=debug\"); env_logger::init(); handle.await } "; /// Services for which accessories need some level of manual adjustment and therefore we don't want to auto-generate an /// accesory for. const NON_IDIOMATIC_SERVICES: &'static [&'static str] = &[ "access code", "accessory information", "accessory metrics", "access control", "accessory runtime information", "asset update", "assistant", "audio stream management", "battery", "camera operating mode", "camera recording management", "camera stream management", "cloud relay", "data stream transport management", "diagnostics", "doorbell", "faucet", "filter maintenance", "heater-cooler", "input source", "irrigation-system", "label", "lightbulb", "lock management", "lock mechanism", "microphone", "nfc access service", "pairing", "power management", "protocol information", "siri", "siri endpoint", "slats", "speaker", "target control management", "target control", "television", "thread transport", "transfer transport management", "valve", "wi-fi transport", ]; /// Services for which we can auto-generate an accessory, but want to skip the example generation because the example /// needs some level of manual adjustment. const SKIP_EXAMPLE_GENERATION: &'static [&'static str] = &["humidifier-dehumidifier"]; /// Example file names that are generated or edited manually and therefore shouldn't be overridden by codegen. const MANUALLY_GENERATED_EXAMPLES: &'static [&'static str] = &[ "adding_accessories_dynamically.rs", "async_callbacks.rs", "bridged_accessories.rs", "callbacks.rs", "cooler.rs", "custom_characteristics_services_accessories.rs", "custom_multi_sensor.rs", "dehumidifier.rs", "faucet.rs", "heater.rs", "humidifier.rs", "irrigation_system.rs", "lightbulb.rs", "lock.rs", "setting_values_after_server_start.rs", "shower_head.rs", "storing_arbitrary_bytes.rs", "sprinkler.rs", "television.rs", ]; // TODO - manual overrides for valve type & media state values fn main() { let metadata_file = File::open("codegen/gen/system.json").unwrap(); let metadata: SystemMetadata = serde_json::from_reader(&metadata_file).unwrap(); let metadata = RenderMetadata::from(metadata); let mut handlebars = Handlebars::new(); handlebars.register_helper("if_eq", Box::new(if_eq_helper)); handlebars.register_helper("trim", Box::new(trim_helper)); handlebars.register_helper("file_name", Box::new(file_name_helper)); handlebars.register_helper("format", Box::new(format_helper)); handlebars.register_helper("type", Box::new(type_helper)); handlebars.register_helper("unit", Box::new(unit_helper)); handlebars.register_helper("category", Box::new(category_helper)); handlebars.register_helper("uuid", Box::new(uuid_helper)); handlebars.register_helper("in_values", Box::new(in_values_helper)); handlebars.register_helper("out_values", Box::new(out_values_helper)); handlebars.register_helper("in_values_enum", Box::new(in_values_enum_helper)); handlebars.register_helper("out_values_enum", Box::new(out_values_enum_helper)); handlebars.register_helper("perms", Box::new(perms_helper)); handlebars.register_helper("float", Box::new(float_helper)); handlebars.register_helper("array_length", Box::new(array_length_helper)); handlebars.register_helper("snake_case", Box::new(snake_case_helper)); handlebars.register_helper("pascal_case", Box::new(pascal_case_helper)); handlebars.register_template_string("categories", CATEGORIES).unwrap(); handlebars.register_template_string("hap_type", HAP_TYPE).unwrap(); // PascalCase camelCase handlebars .register_template_string("characteristic", CHARACTERISTIC) .unwrap(); handlebars .register_template_string("characteristic_mod", CHARACTERISTIC_MOD) .unwrap(); handlebars.register_template_string("service", SERVICE).unwrap(); handlebars.register_template_string("service_mod", SERVICE_MOD).unwrap(); handlebars.register_template_string("accessory", ACCESSORY).unwrap(); handlebars .register_template_string("accessory_mod", ACCESSORY_MOD) .unwrap(); handlebars.register_template_string("example", EXAMPLE).unwrap(); let categories = handlebars.render("categories", &metadata).unwrap(); let categories_path = "src/accessory/category.rs".to_owned(); let mut categories_file = File::create(&categories_path).unwrap(); categories_file.write_all(categories.as_bytes()).unwrap(); let hap_type = handlebars.render("hap_type", &metadata).unwrap(); let hap_type_path = "src/hap_type.rs".to_owned(); let mut hap_type_file = File::create(&hap_type_path).unwrap(); hap_type_file.write_all(hap_type.as_bytes()).unwrap(); let characteristic_base_path = "src/characteristic/generated/"; if std::path::Path::new(&characteristic_base_path).exists() { fs::remove_dir_all(&characteristic_base_path).unwrap(); } fs::create_dir_all(&characteristic_base_path).unwrap(); let mut characteristic_names = vec![]; for (c_name, c) in &metadata.characteristics { let in_values = metadata.characteristic_in_values.get(c_name); let out_values = metadata.characteristic_out_values.get(c_name); let characteristic = handlebars .render( "characteristic", &json!({ "characteristic": c, "in_values": in_values, "out_values": out_values }), ) .unwrap(); let characteristic_file_name = c .name .replace(" ", "_") .replace(".", "_") .replace("-", "_") .to_lowercase(); let mut characteristic_path = String::from(characteristic_base_path); characteristic_path.push_str(&characteristic_file_name); characteristic_path.push_str(".rs"); let mut characteristic_file = File::create(&characteristic_path).unwrap(); characteristic_file.write_all(characteristic.as_bytes()).unwrap(); characteristic_names.push(json!({ "name": c.name, "file_name": characteristic_file_name })); } characteristic_names.sort_by(|a, b| { a.get("file_name") .unwrap() .as_str() .unwrap() .cmp(&b.get("file_name").unwrap().as_str().unwrap()) }); let characteristic_mod = handlebars .render( "characteristic_mod", &json!({ "characteristics": characteristic_names }), ) .unwrap(); let mut characteristic_mod_file = File::create(&format!("{}mod.rs", characteristic_base_path)).unwrap(); characteristic_mod_file .write_all(characteristic_mod.as_bytes()) .unwrap(); let service_base_path = "src/service/generated/"; let accessory_base_path = "src/accessory/generated/"; if std::path::Path::new(&service_base_path).exists() { fs::remove_dir_all(&service_base_path).unwrap(); } if std::path::Path::new(&accessory_base_path).exists() { fs::remove_dir_all(&accessory_base_path).unwrap(); } for entry in fs::read_dir("examples").unwrap() { let entry = entry.unwrap(); if entry.file_type().unwrap().is_file() && !MANUALLY_GENERATED_EXAMPLES.contains(&entry.file_name().to_str().unwrap()) { fs::remove_file(entry.path()).unwrap(); } } fs::create_dir_all(&service_base_path).unwrap(); fs::create_dir_all(&accessory_base_path).unwrap(); let mut service_names = vec![]; let mut accessory_names = vec![]; for s in &metadata.sorted_services { let mut required_characteristics = Vec::new(); let mut optional_characteristics = Vec::new(); for c in &s.characteristics.required_characteristics { required_characteristics.push(metadata.characteristics.get(c).unwrap().clone()); } if let Some(o_cs) = &s.characteristics.optional_characteristics { for c in o_cs { optional_characteristics.push(metadata.characteristics.get(c).unwrap().clone()); } } let service = handlebars .render( "service", &json!({ "service": s, "required_characteristics": &required_characteristics, "optional_characteristics": &optional_characteristics, }), ) .unwrap(); let service_file_name = s .name .replace(" ", "_") .replace(".", "_") .replace("-", "_") .to_lowercase(); let mut service_path = String::from(service_base_path); service_path.push_str(&service_file_name); service_path.push_str(".rs"); let mut service_file = File::create(&service_path).unwrap(); service_file.write_all(service.as_bytes()).unwrap(); service_names.push(json!({ "name": s.name.clone(), "file_name": service_file_name.clone() })); if !NON_IDIOMATIC_SERVICES.contains(&s.name.to_lowercase().as_str()) { let accessory = handlebars .render( "accessory", &json!({"service": s, "characteristics": &metadata.characteristics}), ) .unwrap(); let mut accessory_path = String::from(accessory_base_path); accessory_path.push_str(&service_file_name); accessory_path.push_str(".rs"); let mut accessory_file = File::create(&accessory_path).unwrap(); accessory_file.write_all(accessory.as_bytes()).unwrap(); if !SKIP_EXAMPLE_GENERATION.contains(&s.name.to_lowercase().as_str()) { let example = handlebars.render("example", &json!({ "service": s })).unwrap(); let mut example_path = String::from("examples/"); example_path.push_str(&service_file_name); example_path.push_str(".rs"); let mut example_file = File::create(&example_path).unwrap(); example_file.write_all(example.as_bytes()).unwrap(); } accessory_names.push(json!({ "name": s.name.clone(), "file_name": service_file_name })); } } let service_mod = handlebars .render("service_mod", &json!({ "services": service_names })) .unwrap(); let mut service_mod_file = File::create(&format!("{}mod.rs", service_base_path)).unwrap(); service_mod_file.write_all(service_mod.as_bytes()).unwrap(); let accessory_mod = handlebars .render("accessory_mod", &json!({ "accessories": accessory_names })) .unwrap(); let mut accessory_mod_file = File::create(&format!("{}mod.rs", accessory_base_path)).unwrap(); accessory_mod_file.write_all(accessory_mod.as_bytes()).unwrap(); } ================================================ FILE: examples/adding_accessories_dynamically.rs ================================================ use tokio; use hap::{ accessory::{bridge::BridgeAccessory, lightbulb::LightbulbAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let bridge = BridgeAccessory::new(1, AccessoryInformation { name: "Acme Bridge".into(), ..Default::default() })?; let lightbulb = LightbulbAccessory::new(2, AccessoryInformation { name: "Acme Lightbulb".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Bridge".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Bridge, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(bridge).await?; server.add_accessory(lightbulb).await?; let handle = server.run_handle(); let stream_of_new_accessories = async { tokio::time::sleep(std::time::Duration::from_secs(60)).await; for i in 0..20 { let lightbulb = LightbulbAccessory::new(i + 3, AccessoryInformation { name: format!("Another Lightbulb {}", i + 1), ..Default::default() })?; server.add_accessory(lightbulb).await?; tokio::time::sleep(std::time::Duration::from_secs(2)).await; } Ok(()) }; std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); futures::try_join!(handle, stream_of_new_accessories)?; Ok(()) } ================================================ FILE: examples/air_purifier.rs ================================================ use tokio; use hap::{ accessory::{air_purifier::AirPurifierAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let air_purifier = AirPurifierAccessory::new(1, AccessoryInformation { name: "Acme Air Purifier".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Air Purifier".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::AirPurifier, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(air_purifier).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/air_quality_sensor.rs ================================================ use tokio; use hap::{ accessory::{air_quality_sensor::AirQualitySensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let air_quality_sensor = AirQualitySensorAccessory::new(1, AccessoryInformation { name: "Acme Air Quality Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Air Quality Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(air_quality_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/async_callbacks.rs ================================================ use tokio; use hap::{ accessory::{lightbulb::LightbulbAccessory, AccessoryCategory, AccessoryInformation}, characteristic::AsyncCharacteristicCallbacks, futures::future::FutureExt, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let mut lightbulb = LightbulbAccessory::new(1, AccessoryInformation { name: "Acme Lightbulb".into(), ..Default::default() })?; lightbulb.lightbulb.power_state.on_read_async(Some(|| { async { println!("power_state characteristic read"); Ok(None) } .boxed() })); lightbulb .lightbulb .power_state .on_update_async(Some(|current_val: bool, new_val: bool| { async move { println!("power_state characteristic updated from {} to {}", current_val, new_val); Ok(()) } .boxed() })); let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Lightbulb".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Lightbulb, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(lightbulb).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/bridged_accessories.rs ================================================ use tokio; use hap::{ accessory::{bridge::BridgeAccessory, lightbulb::LightbulbAccessory, AccessoryCategory, AccessoryInformation}, characteristic::CharacteristicCallbacks, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let bridge = BridgeAccessory::new(1, AccessoryInformation { name: "Acme Bridge".into(), ..Default::default() })?; let mut lightbulb_1 = LightbulbAccessory::new(2, AccessoryInformation { name: "Lightbulb 1".into(), ..Default::default() })?; let mut lightbulb_2 = LightbulbAccessory::new(3, AccessoryInformation { name: "Lightbulb 2".into(), ..Default::default() })?; let mut lightbulb_3 = LightbulbAccessory::new(4, AccessoryInformation { name: "Lightbulb 3".into(), ..Default::default() })?; lightbulb_1 .lightbulb .power_state .on_update(Some(|current_val: &bool, new_val: &bool| { println!( "Lightbulb 1: power_state characteristic updated from {} to {}", current_val, new_val ); Ok(()) })); lightbulb_2 .lightbulb .power_state .on_update(Some(|current_val: &bool, new_val: &bool| { println!( "Lightbulb 2: power_state characteristic updated from {} to {}", current_val, new_val ); Ok(()) })); lightbulb_3 .lightbulb .power_state .on_update(Some(|current_val: &bool, new_val: &bool| { println!( "Lightbulb 3: power_state characteristic updated from {} to {}", current_val, new_val ); Ok(()) })); let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Bridge".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Bridge, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(bridge).await?; server.add_accessory(lightbulb_1).await?; server.add_accessory(lightbulb_2).await?; server.add_accessory(lightbulb_3).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/callbacks.rs ================================================ use tokio; use hap::{ accessory::{lightbulb::LightbulbAccessory, AccessoryCategory, AccessoryInformation}, characteristic::CharacteristicCallbacks, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let mut lightbulb = LightbulbAccessory::new(1, AccessoryInformation { name: "Acme Lightbulb".into(), ..Default::default() })?; lightbulb.lightbulb.power_state.on_read(Some(|| { println!("power_state characteristic read"); Ok(None) })); lightbulb .lightbulb .power_state .on_update(Some(|current_val: &bool, new_val: &bool| { println!("power_state characteristic updated from {} to {}", current_val, new_val); Ok(()) })); let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Lightbulb".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Lightbulb, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(lightbulb).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/carbon_dioxide_sensor.rs ================================================ use tokio; use hap::{ accessory::{carbon_dioxide_sensor::CarbonDioxideSensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let carbon_dioxide_sensor = CarbonDioxideSensorAccessory::new(1, AccessoryInformation { name: "Acme Carbon dioxide Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Carbon dioxide Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(carbon_dioxide_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/carbon_monoxide_sensor.rs ================================================ use tokio; use hap::{ accessory::{carbon_monoxide_sensor::CarbonMonoxideSensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let carbon_monoxide_sensor = CarbonMonoxideSensorAccessory::new(1, AccessoryInformation { name: "Acme Carbon monoxide Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Carbon monoxide Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(carbon_monoxide_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/contact_sensor.rs ================================================ use tokio; use hap::{ accessory::{contact_sensor::ContactSensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let contact_sensor = ContactSensorAccessory::new(1, AccessoryInformation { name: "Acme Contact Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Contact Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(contact_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/cooler.rs ================================================ use tokio; use hap::{ accessory::{heater_cooler::HeaterCoolerAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let cooler = HeaterCoolerAccessory::new(1, AccessoryInformation { name: "Acme Cooler".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Cooler".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::AirConditioner, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(cooler).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/custom_characteristics_services_accessories.rs ================================================ use serde::{ ser::{SerializeStruct, Serializer}, Serialize, }; use tokio; use uuid::Uuid; use hap::{ accessory::{AccessoryCategory, AccessoryInformation, HapAccessory}, characteristic::{Characteristic, Format, HapCharacteristic, Perm}, server::{IpServer, Server}, service::{accessory_information::AccessoryInformationService, HapService}, storage::{FileStorage, Storage}, Config, HapType, MacAddress, Pin, Result, }; // creating a custom service /// Foo service. #[derive(Debug, Default)] pub struct FooService { /// Instance ID of the Foo service. id: u64, /// [`HapType`](HapType) of the Foo service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Foo Number characteristic (required). pub foo_number: Characteristic, /// Foo Name characteristic (required). pub foo_name: Characteristic, } impl HapService for FooService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { vec![&self.foo_number, &self.foo_name] } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { vec![&mut self.foo_number, &mut self.foo_name] } } impl serde::ser::Serialize for FooService { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } // creating a custom accessory /// Foo accessory. #[derive(Debug, Default)] pub struct FooAccessory { /// ID of the Foo accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Foo service. pub foo: FooService, } impl HapAccessory for FooAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information, &self.foo] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![&mut self.accessory_information, &mut self.foo] } } impl Serialize for FooAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } #[tokio::main] async fn main() -> Result<()> { // Custom Foo Number characteristic. let foo_number = Characteristic::::new( 8, 1, HapType::Custom(Uuid::parse_str("2db3ac3f-8b9c-4431-8d87-670351dc872a").unwrap()), Format::UInt8, vec![Perm::PairedRead], Some("Foo Number Characteristic".to_string()), None, 42, None, None, None, None, None, None, None, None, None, None, ); // Custom Foo Name characteristic. let foo_name = Characteristic::::new( 9, 1, HapType::Custom(Uuid::parse_str("497c968e-261f-445d-bcac-69ae7bb8979b").unwrap()), Format::String, vec![Perm::PairedRead], Some("Foo Name Characteristic".to_string()), None, "Horst".to_string(), None, None, None, None, None, None, None, None, None, None, ); // Custom Foo service. let foo_service = FooService { id: 7, // accessory information service ends at IID 6, so we start counting at 7 hap_type: HapType::Custom(Uuid::parse_str("d5bb0a60-92f0-483e-811d-97d4b2b502ff").unwrap()), hidden: false, primary: true, linked_services: vec![], foo_number, foo_name, }; // Custom Foo accessory. let mut foo_accessory = FooAccessory { id: 1, accessory_information: AccessoryInformation { name: "Acme Foo".into(), ..Default::default() } .to_service(1, 1)?, foo: foo_service, }; foo_accessory.foo.foo_number.on_read(Some(|| { println!("foo_number characteristic read"); Ok(None) })); foo_accessory.foo.foo_name.on_read(Some(|| { println!("foo_name characteristic read"); Ok(None) })); let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Foo".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Other, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(foo_accessory).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/custom_multi_sensor.rs ================================================ use serde::{ ser::{SerializeStruct, Serializer}, Serialize, }; use tokio; use hap::{ accessory::{AccessoryCategory, AccessoryInformation, HapAccessory}, server::{IpServer, Server}, service::{ accessory_information::AccessoryInformationService, humidity_sensor::HumiditySensorService, temperature_sensor::TemperatureSensorService, HapService, }, storage::{FileStorage, Storage}, Config, HapType, MacAddress, Pin, Result, }; /// Multi Sensor accessory. #[derive(Debug, Default)] pub struct MultiSensorAccessory { /// ID of the Multi Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Temperature Sensor service. pub temperature_sensor: TemperatureSensorService, /// Humidity Sensor service. pub humidity_sensor: HumiditySensorService, } impl HapAccessory for MultiSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.temperature_sensor, &self.humidity_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.temperature_sensor, &mut self.humidity_sensor, ] } } impl Serialize for MultiSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } #[tokio::main] async fn main() -> Result<()> { let multi_sensor = MultiSensorAccessory { id: 1, accessory_information: AccessoryInformation { name: "Acme Temperature & Humidity Sensor".into(), ..Default::default() } .to_service(1, 1)?, // accessory information service ends at IID 6, so we start counting at 7 temperature_sensor: TemperatureSensorService::new(7, 1), // teperature sensor service ends at IID 13, so we start counting at 14 humidity_sensor: HumiditySensorService::new(14, 1), }; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Temperature & Humidity Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(multi_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/dehumidifier.rs ================================================ use tokio; use hap::{ accessory::{humidifier_dehumidifier::HumidifierDehumidifierAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let dehumidifier = HumidifierDehumidifierAccessory::new(1, AccessoryInformation { name: "Acme Dehumidifier".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Dehumidifier".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::AirDehumidifier, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(dehumidifier).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/door.rs ================================================ use tokio; use hap::{ accessory::{door::DoorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let door = DoorAccessory::new(1, AccessoryInformation { name: "Acme Door".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Door".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Door, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(door).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/fan.rs ================================================ use tokio; use hap::{ accessory::{fan::FanAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let fan = FanAccessory::new(1, AccessoryInformation { name: "Acme Fan".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Fan".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Fan, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(fan).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/fan_v2.rs ================================================ use tokio; use hap::{ accessory::{fan_v2::FanV2Accessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let fan_v2 = FanV2Accessory::new(1, AccessoryInformation { name: "Acme Fan v2".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Fan v2".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Fan, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(fan_v2).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/faucet.rs ================================================ use tokio; use hap::{ accessory::{faucet::FaucetAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let faucet = FaucetAccessory::new(1, AccessoryInformation { name: "Acme Faucet".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Faucet".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Faucet, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(faucet).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/garage_door_opener.rs ================================================ use tokio; use hap::{ accessory::{garage_door_opener::GarageDoorOpenerAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let garage_door_opener = GarageDoorOpenerAccessory::new(1, AccessoryInformation { name: "Acme Garage Door Opener".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Garage Door Opener".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::GarageDoorOpener, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(garage_door_opener).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/heater.rs ================================================ use tokio; use hap::{ accessory::{heater_cooler::HeaterCoolerAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let heater = HeaterCoolerAccessory::new(1, AccessoryInformation { name: "Acme Heater".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Heater".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::AirHeater, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(heater).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/humidifier.rs ================================================ use tokio; use hap::{ accessory::{humidifier_dehumidifier::HumidifierDehumidifierAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let humidifier = HumidifierDehumidifierAccessory::new(1, AccessoryInformation { name: "Acme Humidifier".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Humidifier-Dehumidifier".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::AirDehumidifier, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(humidifier).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/humidity_sensor.rs ================================================ use tokio; use hap::{ accessory::{humidity_sensor::HumiditySensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let humidity_sensor = HumiditySensorAccessory::new(1, AccessoryInformation { name: "Acme Humidity Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Humidity Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(humidity_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/irrigation_system.rs ================================================ use tokio; use hap::{ accessory::{irrigation_system::IrrigationSystemAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let irrigation_system = IrrigationSystemAccessory::new(1, AccessoryInformation { name: "Acme Irrigation-System".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Irrigation-System".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sprinkler, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(irrigation_system).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/leak_sensor.rs ================================================ use tokio; use hap::{ accessory::{leak_sensor::LeakSensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let leak_sensor = LeakSensorAccessory::new(1, AccessoryInformation { name: "Acme Leak Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Leak Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(leak_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/light_sensor.rs ================================================ use tokio; use hap::{ accessory::{light_sensor::LightSensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let light_sensor = LightSensorAccessory::new(1, AccessoryInformation { name: "Acme Light Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Light Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(light_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/lightbulb.rs ================================================ use tokio; use hap::{ accessory::{lightbulb::LightbulbAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let lightbulb = LightbulbAccessory::new(1, AccessoryInformation { name: "Acme Lightbulb".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Lightbulb".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Lightbulb, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(lightbulb).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/lock.rs ================================================ use tokio; use hap::{ accessory::{lock::LockAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let lock = LockAccessory::new(1, AccessoryInformation { name: "Acme Lock".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Lock".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::DoorLock, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(lock).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/motion_sensor.rs ================================================ use tokio; use hap::{ accessory::{motion_sensor::MotionSensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let motion_sensor = MotionSensorAccessory::new(1, AccessoryInformation { name: "Acme Motion Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Motion Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(motion_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/occupancy_sensor.rs ================================================ use tokio; use hap::{ accessory::{occupancy_sensor::OccupancySensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let occupancy_sensor = OccupancySensorAccessory::new(1, AccessoryInformation { name: "Acme Occupancy Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Occupancy Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(occupancy_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/outlet.rs ================================================ use tokio; use hap::{ accessory::{outlet::OutletAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let outlet = OutletAccessory::new(1, AccessoryInformation { name: "Acme Outlet".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Outlet".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Outlet, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(outlet).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/security_system.rs ================================================ use tokio; use hap::{ accessory::{security_system::SecuritySystemAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let security_system = SecuritySystemAccessory::new(1, AccessoryInformation { name: "Acme Security System".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Security System".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::SecuritySystem, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(security_system).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/setting_values_after_server_start.rs ================================================ use tokio; use hap::{ accessory::{motion_sensor::MotionSensorAccessory, AccessoryCategory, AccessoryInformation}, serde_json::Value, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, HapType, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let sensor = MotionSensorAccessory::new(1, AccessoryInformation { name: "Acme Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 63]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; let sensor_ptr = server.add_accessory(sensor).await?; let handle = server.run_handle(); let value_set_interval = async move { let mut interval = tokio::time::interval(std::time::Duration::from_secs(2)); tokio::time::sleep(std::time::Duration::from_secs(60)).await; loop { interval.tick().await; let mut motion_sensor_accessory = sensor_ptr.lock().await; let motion_sensor_service = motion_sensor_accessory.get_mut_service(HapType::MotionSensor).unwrap(); let motion_detected_characteristic = motion_sensor_service .get_mut_characteristic(HapType::MotionDetected) .unwrap(); motion_detected_characteristic.set_value(Value::Bool(true)).await?; tokio::time::sleep(std::time::Duration::from_secs(1)).await; motion_detected_characteristic.set_value(Value::Bool(false)).await?; } #[allow(unreachable_code)] Ok(()) }; std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); futures::try_join!(handle, value_set_interval)?; Ok(()) } ================================================ FILE: examples/shower_head.rs ================================================ use tokio; use hap::{ accessory::{shower_head::ShowerHeadAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let shower_head = ShowerHeadAccessory::new(1, AccessoryInformation { name: "Acme Shower Head".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Shower Head".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::ShowerHead, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(shower_head).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/smart_speaker.rs ================================================ use tokio; use hap::{ accessory::{smart_speaker::SmartSpeakerAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let smart_speaker = SmartSpeakerAccessory::new(1, AccessoryInformation { name: "Acme Smart Speaker".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Smart Speaker".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Speaker, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(smart_speaker).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/smoke_sensor.rs ================================================ use tokio; use hap::{ accessory::{smoke_sensor::SmokeSensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let smoke_sensor = SmokeSensorAccessory::new(1, AccessoryInformation { name: "Acme Smoke Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Smoke Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(smoke_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/stateful_programmable_switch.rs ================================================ use tokio; use hap::{ accessory::{ stateful_programmable_switch::StatefulProgrammableSwitchAccessory, AccessoryCategory, AccessoryInformation, }, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let stateful_programmable_switch = StatefulProgrammableSwitchAccessory::new(1, AccessoryInformation { name: "Acme Stateful Programmable Switch".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Stateful Programmable Switch".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::ProgrammableSwitch, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(stateful_programmable_switch).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/stateless_programmable_switch.rs ================================================ use tokio; use hap::{ accessory::{ stateless_programmable_switch::StatelessProgrammableSwitchAccessory, AccessoryCategory, AccessoryInformation, }, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let stateless_programmable_switch = StatelessProgrammableSwitchAccessory::new(1, AccessoryInformation { name: "Acme Stateless Programmable Switch".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Stateless Programmable Switch".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::ProgrammableSwitch, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(stateless_programmable_switch).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/storing_arbitrary_bytes.rs ================================================ use serde::{Deserialize, Serialize}; use std::sync::Arc; use tokio::sync::Mutex; use hap::{ accessory::{lightbulb::LightbulbAccessory, AccessoryCategory, AccessoryInformation}, characteristic::AsyncCharacteristicCallbacks, futures::future::FutureExt, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[derive(Debug, Serialize, Deserialize)] struct LightbulbState { pub power_state: bool, } #[tokio::main] async fn main() -> Result<()> { let mut lightbulb = LightbulbAccessory::new(1, AccessoryInformation { name: "Acme Stateful Lightbulb".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Stateful Lightbulb".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Lightbulb, ..Default::default() }; storage.save_config(&config).await?; config }, }; let state = Arc::new(Mutex::new(match storage.load_bytes("state.json").await { Ok(state_bytes) => { let state = serde_json::from_slice(&state_bytes)?; state }, Err(_) => { let state = LightbulbState { power_state: false }; let state_bytes = serde_json::to_vec(&state)?; storage.save_bytes("state.json", &state_bytes).await?; state }, })); let state_ = state.clone(); lightbulb.lightbulb.power_state.on_read_async(Some(move || { let state = state_.clone(); async move { let power_state = state.lock().await.power_state; println!("power_state characteristic read from state: {}", &power_state); // have the controller read the value from state Ok(Some(power_state)) } .boxed() })); // TODO - creating another FileStorage instance on the same underlying directory isn't that elegant let state_storage = Arc::new(Mutex::new(FileStorage::current_dir().await?)); let state_ = state.clone(); let state_storage_ = state_storage.clone(); lightbulb .lightbulb .power_state .on_update_async(Some(move |current_val: bool, new_val: bool| { let state = state_.clone(); let storage = state_storage_.clone(); async move { if current_val != new_val { let mut s = state.lock().await; s.power_state = new_val; // persist the new value let state_bytes = serde_json::to_vec(&*s)?; storage.lock().await.save_bytes("state.json", &state_bytes).await?; } println!("power_state characteristic updated from {} to {}", current_val, new_val); Ok(()) } .boxed() })); let server = IpServer::new(config, storage).await?; server.add_accessory(lightbulb).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/switch.rs ================================================ use tokio; use hap::{ accessory::{switch::SwitchAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let switch = SwitchAccessory::new(1, AccessoryInformation { name: "Acme Switch".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Switch".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Switch, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(switch).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/television.rs ================================================ use tokio; use hap::{ accessory::{television::TelevisionAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let television = TelevisionAccessory::new(1, AccessoryInformation { name: "Acme Television".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Television".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Television, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(television).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/temperature_sensor.rs ================================================ use tokio; use hap::{ accessory::{temperature_sensor::TemperatureSensorAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let temperature_sensor = TemperatureSensorAccessory::new(1, AccessoryInformation { name: "Acme Temperature Sensor".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Temperature Sensor".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Sensor, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(temperature_sensor).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/thermostat.rs ================================================ use tokio; use hap::{ accessory::{thermostat::ThermostatAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let thermostat = ThermostatAccessory::new(1, AccessoryInformation { name: "Acme Thermostat".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Thermostat".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Thermostat, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(thermostat).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/wi_fi_router.rs ================================================ use tokio; use hap::{ accessory::{wi_fi_router::WiFiRouterAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let wi_fi_router = WiFiRouterAccessory::new(1, AccessoryInformation { name: "Acme Wi-Fi Router".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Wi-Fi Router".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::WiFiRouter, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(wi_fi_router).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/wi_fi_satellite.rs ================================================ use tokio; use hap::{ accessory::{wi_fi_satellite::WiFiSatelliteAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let wi_fi_satellite = WiFiSatelliteAccessory::new(1, AccessoryInformation { name: "Acme Wi-Fi Satellite".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Wi-Fi Satellite".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::WiFiRouter, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(wi_fi_satellite).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/window.rs ================================================ use tokio; use hap::{ accessory::{window::WindowAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let window = WindowAccessory::new(1, AccessoryInformation { name: "Acme Window".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Window".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::Window, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(window).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: examples/window_covering.rs ================================================ use tokio; use hap::{ accessory::{window_covering::WindowCoveringAccessory, AccessoryCategory, AccessoryInformation}, server::{IpServer, Server}, storage::{FileStorage, Storage}, Config, MacAddress, Pin, Result, }; #[tokio::main] async fn main() -> Result<()> { let window_covering = WindowCoveringAccessory::new(1, AccessoryInformation { name: "Acme Window Covering".into(), ..Default::default() })?; let mut storage = FileStorage::current_dir().await?; let config = match storage.load_config().await { Ok(mut config) => { config.redetermine_local_ip(); storage.save_config(&config).await?; config }, Err(_) => { let config = Config { pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, name: "Acme Window Covering".into(), device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), category: AccessoryCategory::WindowCovering, ..Default::default() }; storage.save_config(&config).await?; config }, }; let server = IpServer::new(config, storage).await?; server.add_accessory(window_covering).await?; let handle = server.run_handle(); std::env::set_var("RUST_LOG", "hap=debug"); env_logger::init(); handle.await } ================================================ FILE: rls.toml ================================================ build_on_save = true ================================================ FILE: rustfmt.toml ================================================ edition = "2018" unstable_features = true version = "Two" comment_width = 120 fn_single_line = true format_code_in_doc_comments = true format_macro_bodies = true format_macro_matchers = true imports_granularity = "Crate" imports_layout = "HorizontalVertical" match_arm_blocks = false match_block_trailing_comma = true max_width = 120 overflow_delimited_expr = true reorder_impl_items = true use_field_init_shorthand = true use_try_shorthand = true wrap_comments = true ignore = [ "src/accessory/generated/*", "src/accessory/category.rs", "src/characteristic/generated/*", "src/service/generated/*", "src/hap_type.rs", ] ================================================ FILE: src/accessory/category.rs ================================================ // this file is auto-generated by hap-codegen use serde::{Deserialize, Serialize}; /// HAP accessory category. #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq)] pub enum AccessoryCategory { Other = 1, Bridge = 2, Fan = 3, GarageDoorOpener = 4, Lightbulb = 5, DoorLock = 6, Outlet = 7, Switch = 8, Thermostat = 9, Sensor = 10, SecuritySystem = 11, Door = 12, Window = 13, WindowCovering = 14, ProgrammableSwitch = 15, RangeExtender = 16, IpCamera = 17, VideoDoorbell = 18, AirPurifier = 19, AirHeater = 20, AirConditioner = 21, AirHumidifier = 22, AirDehumidifier = 23, AppleTv = 24, Speaker = 26, Airport = 27, Sprinkler = 28, Faucet = 29, ShowerHead = 30, Television = 31, TargetController = 32, WiFiRouter = 33, AudioReceiver = 34, TelevisionSetTopBox = 35, TelevisionStreamingStick = 36, } ================================================ FILE: src/accessory/defined/bridge.rs ================================================ use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{accessory_information::AccessoryInformationService, HapService}, HapType, Result, }; /// Bridge Accessory. #[derive(Debug, Default)] pub struct BridgeAccessory { /// ID of the Bridge Accessory. id: u64, /// Accessory Information Service. pub accessory_information: AccessoryInformationService, } impl BridgeAccessory { /// Creates a new Bridge Accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; Ok(Self { id, accessory_information, }) } } impl HapAccessory for BridgeAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![&mut self.accessory_information] } } impl Serialize for BridgeAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/defined/faucet.rs ================================================ use futures::executor; use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, characteristic::HapCharacteristic, service::{accessory_information::AccessoryInformationService, valve::ValveService, HapService}, HapType, Result, }; /// Faucet Accessory. #[derive(Debug, Default)] pub struct FaucetAccessory { /// ID of the Faucet Accessory. id: u64, /// Accessory Information Service. pub accessory_information: AccessoryInformationService, /// Valve Service. pub valve: ValveService, } impl FaucetAccessory { /// Creates a new Faucet Accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let valve_id = 2 + accessory_information.get_characteristics().len() as u64; let mut valve = ValveService::new(valve_id, id); valve.set_primary(true); executor::block_on(valve.valve_type.set_value(3.into()))?; // 3 is FAUCET Ok(Self { id, accessory_information, valve, }) } } impl HapAccessory for FaucetAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information, &self.valve] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![&mut self.accessory_information, &mut self.valve] } } impl Serialize for FaucetAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/defined/heater_cooler.rs ================================================ use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{accessory_information::AccessoryInformationService, heater_cooler::HeaterCoolerService, HapService}, HapType, Result, }; /// Heater-Cooler Accessory. #[derive(Debug, Default)] pub struct HeaterCoolerAccessory { /// ID of the Heater-Cooler Accessory. id: u64, /// Accessory Information Service. pub accessory_information: AccessoryInformationService, /// Heater-Cooler Service. pub heater_cooler: HeaterCoolerService, } impl HeaterCoolerAccessory { /// Creates a new Heater-Cooler Accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let heater_cooler_id = accessory_information.get_characteristics().len() as u64; let mut heater_cooler = HeaterCoolerService::new(1 + heater_cooler_id + 1, id); heater_cooler.set_primary(true); Ok(Self { id, accessory_information, heater_cooler, }) } } impl HapAccessory for HeaterCoolerAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information, &self.heater_cooler] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![&mut self.accessory_information, &mut self.heater_cooler] } } impl Serialize for HeaterCoolerAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/defined/irrigation_system.rs ================================================ use futures::executor; use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, characteristic::HapCharacteristic, service::{accessory_information::AccessoryInformationService, valve::ValveService, HapService}, HapType, Result, }; /// Irrigation-System Accessory. #[derive(Debug, Default)] pub struct IrrigationSystemAccessory { /// ID of the Irrigation-System Accessory. id: u64, /// Accessory Information Service. pub accessory_information: AccessoryInformationService, /// Valve Service. pub valve: ValveService, } impl IrrigationSystemAccessory { /// Creates a new Irrigation-System Accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; // adding multiple valves here would result in an irrigation system with multiple "Zones" let valve_id = 2 + accessory_information.get_characteristics().len() as u64; let mut valve = ValveService::new(valve_id, id); valve.set_primary(true); executor::block_on(valve.valve_type.set_value(1.into()))?; // 1 is IRRIGATION/SPRINKLER Ok(Self { id, accessory_information, valve, }) } } impl HapAccessory for IrrigationSystemAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information, &self.valve] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![&mut self.accessory_information, &mut self.valve] } } impl Serialize for IrrigationSystemAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/defined/lightbulb.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{accessory_information::AccessoryInformationService, lightbulb::LightbulbService, HapService}, HapType, Result, }; /// Lightbulb Accessory. #[derive(Debug, Default)] pub struct LightbulbAccessory { /// ID of the Lightbulb Accessory. id: u64, /// Accessory Information Service. pub accessory_information: AccessoryInformationService, /// Lightbulb Service. pub lightbulb: LightbulbService, } impl LightbulbAccessory { /// Creates a new Lightbulb Accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let lightbulb_id = accessory_information.get_characteristics().len() as u64; let mut lightbulb = LightbulbService::new(1 + lightbulb_id + 1, id); lightbulb.set_primary(true); // TODO - this has to do with adaptive lighting and the controller refuses to pair until we figured it out lightbulb.characteristic_value_active_transition_count = None; lightbulb.characteristic_value_transition_control = None; lightbulb.supported_characteristic_value_transition_configuration = None; Ok(Self { id, accessory_information, lightbulb, }) } } impl HapAccessory for LightbulbAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information, &self.lightbulb] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![&mut self.accessory_information, &mut self.lightbulb] } } impl Serialize for LightbulbAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/defined/lock.rs ================================================ use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{ accessory_information::AccessoryInformationService, lock_management::LockManagementService, lock_mechanism::LockMechanismService, HapService, }, HapType, Result, }; /// Lock Accessory. #[derive(Default)] pub struct LockAccessory { /// ID of the Lock Accessory. id: u64, /// Accessory Information Service. pub accessory_information: AccessoryInformationService, /// Lock Mechanism Service. pub lock_mechanism: LockMechanismService, /// Lock Management Service. pub lock_management: LockManagementService, } impl LockAccessory { /// Creates a new Lock Accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let lock_mechanism_id = 2 + accessory_information.get_characteristics().len() as u64; let mut lock_mechanism = LockMechanismService::new(lock_mechanism_id, id); lock_mechanism.set_primary(true); let lock_management_id = 3 + lock_mechanism_id + lock_mechanism.get_characteristics().len() as u64; let mut lock_management = LockManagementService::new(lock_management_id, id); lock_management.set_primary(true); // TODO - figure out how to auto-set reasonable default values for tlv8 characteristics lock_management.logs = None; Ok(Self { id, accessory_information, lock_mechanism, lock_management, }) } } impl HapAccessory for LockAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information, &self.lock_mechanism, &self.lock_management] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.lock_mechanism, &mut self.lock_management, ] } } impl Serialize for LockAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/defined/mod.rs ================================================ /// Bridge accessory definition. pub mod bridge; /// Faucet accessory definition. pub mod faucet; /// Heater-Cooler accessory definition. pub mod heater_cooler; /// Irrigation-System accessory definition. pub mod irrigation_system; /// Lightbulb accessory definition. pub mod lightbulb; /// Lock accessory definition. pub mod lock; /// Shower Head accessory definition. pub mod shower_head; /// Television accessory definition. pub mod television; ================================================ FILE: src/accessory/defined/shower_head.rs ================================================ use futures::executor; use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, characteristic::HapCharacteristic, service::{accessory_information::AccessoryInformationService, valve::ValveService, HapService}, HapType, Result, }; /// Shower Head Accessory. #[derive(Debug, Default)] pub struct ShowerHeadAccessory { /// ID of the Shower Head Accessory. id: u64, /// Accessory Information Service. pub accessory_information: AccessoryInformationService, /// Valve Service. pub valve: ValveService, } impl ShowerHeadAccessory { /// Creates a new Shower Head Accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let valve_id = 2 + accessory_information.get_characteristics().len() as u64; let mut valve = ValveService::new(valve_id, id); valve.set_primary(true); executor::block_on(valve.valve_type.set_value(2.into()))?; // 2 is SHOWER_HEAD Ok(Self { id, accessory_information, valve, }) } } impl HapAccessory for ShowerHeadAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information, &self.valve] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![&mut self.accessory_information, &mut self.valve] } } impl Serialize for ShowerHeadAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/defined/television.rs ================================================ use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{ accessory_information::AccessoryInformationService, speaker::SpeakerService, television::TelevisionService, HapService, }, HapType, Result, }; /// Television Accessory. #[derive(Default)] pub struct TelevisionAccessory { /// ID of the Television Accessory. id: u64, /// Accessory Information Service. pub accessory_information: AccessoryInformationService, /// Television Service. pub television: TelevisionService, /// Speaker Service. pub speaker: SpeakerService, } impl TelevisionAccessory { /// Creates a new Television Accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let television_id = 2 + accessory_information.get_characteristics().len() as u64; let mut television = TelevisionService::new(television_id, id); television.set_primary(true); // TODO - figure out how to auto-set reasonable default values for tlv8 characteristics television.display_order = None; let speaker_id = 3 + television_id + television.get_characteristics().len() as u64; let speaker = SpeakerService::new(speaker_id, id); Ok(Self { id, accessory_information, television, speaker, }) } } impl HapAccessory for TelevisionAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![&self.accessory_information, &self.television, &self.speaker] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![&mut self.accessory_information, &mut self.television, &mut self.speaker] } } impl Serialize for TelevisionAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/air_purifier.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, air_purifier::AirPurifierService}, HapType, Result, }; /// Air Purifier accessory. #[derive(Debug, Default)] pub struct AirPurifierAccessory { /// ID of the Air Purifier accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Air Purifier service. pub air_purifier: AirPurifierService, } impl AirPurifierAccessory { /// Creates a new Air Purifier accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let air_purifier_id = accessory_information.get_characteristics().len() as u64; let mut air_purifier = AirPurifierService::new(1 + air_purifier_id + 1, id); air_purifier.set_primary(true); Ok(Self { id, accessory_information, air_purifier, }) } } impl HapAccessory for AirPurifierAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.air_purifier, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.air_purifier, ] } } impl Serialize for AirPurifierAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/air_quality_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, air_quality_sensor::AirQualitySensorService}, HapType, Result, }; /// Air Quality Sensor accessory. #[derive(Debug, Default)] pub struct AirQualitySensorAccessory { /// ID of the Air Quality Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Air Quality Sensor service. pub air_quality_sensor: AirQualitySensorService, } impl AirQualitySensorAccessory { /// Creates a new Air Quality Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let air_quality_sensor_id = accessory_information.get_characteristics().len() as u64; let mut air_quality_sensor = AirQualitySensorService::new(1 + air_quality_sensor_id + 1, id); air_quality_sensor.set_primary(true); Ok(Self { id, accessory_information, air_quality_sensor, }) } } impl HapAccessory for AirQualitySensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.air_quality_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.air_quality_sensor, ] } } impl Serialize for AirQualitySensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/carbon_dioxide_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, carbon_dioxide_sensor::CarbonDioxideSensorService}, HapType, Result, }; /// Carbon dioxide Sensor accessory. #[derive(Debug, Default)] pub struct CarbonDioxideSensorAccessory { /// ID of the Carbon dioxide Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Carbon dioxide Sensor service. pub carbon_dioxide_sensor: CarbonDioxideSensorService, } impl CarbonDioxideSensorAccessory { /// Creates a new Carbon dioxide Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let carbon_dioxide_sensor_id = accessory_information.get_characteristics().len() as u64; let mut carbon_dioxide_sensor = CarbonDioxideSensorService::new(1 + carbon_dioxide_sensor_id + 1, id); carbon_dioxide_sensor.set_primary(true); Ok(Self { id, accessory_information, carbon_dioxide_sensor, }) } } impl HapAccessory for CarbonDioxideSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.carbon_dioxide_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.carbon_dioxide_sensor, ] } } impl Serialize for CarbonDioxideSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/carbon_monoxide_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, carbon_monoxide_sensor::CarbonMonoxideSensorService}, HapType, Result, }; /// Carbon monoxide Sensor accessory. #[derive(Debug, Default)] pub struct CarbonMonoxideSensorAccessory { /// ID of the Carbon monoxide Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Carbon monoxide Sensor service. pub carbon_monoxide_sensor: CarbonMonoxideSensorService, } impl CarbonMonoxideSensorAccessory { /// Creates a new Carbon monoxide Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let carbon_monoxide_sensor_id = accessory_information.get_characteristics().len() as u64; let mut carbon_monoxide_sensor = CarbonMonoxideSensorService::new(1 + carbon_monoxide_sensor_id + 1, id); carbon_monoxide_sensor.set_primary(true); Ok(Self { id, accessory_information, carbon_monoxide_sensor, }) } } impl HapAccessory for CarbonMonoxideSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.carbon_monoxide_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.carbon_monoxide_sensor, ] } } impl Serialize for CarbonMonoxideSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/contact_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, contact_sensor::ContactSensorService}, HapType, Result, }; /// Contact Sensor accessory. #[derive(Debug, Default)] pub struct ContactSensorAccessory { /// ID of the Contact Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Contact Sensor service. pub contact_sensor: ContactSensorService, } impl ContactSensorAccessory { /// Creates a new Contact Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let contact_sensor_id = accessory_information.get_characteristics().len() as u64; let mut contact_sensor = ContactSensorService::new(1 + contact_sensor_id + 1, id); contact_sensor.set_primary(true); Ok(Self { id, accessory_information, contact_sensor, }) } } impl HapAccessory for ContactSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.contact_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.contact_sensor, ] } } impl Serialize for ContactSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/door.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, door::DoorService}, HapType, Result, }; /// Door accessory. #[derive(Debug, Default)] pub struct DoorAccessory { /// ID of the Door accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Door service. pub door: DoorService, } impl DoorAccessory { /// Creates a new Door accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let door_id = accessory_information.get_characteristics().len() as u64; let mut door = DoorService::new(1 + door_id + 1, id); door.set_primary(true); Ok(Self { id, accessory_information, door, }) } } impl HapAccessory for DoorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.door, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.door, ] } } impl Serialize for DoorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/fan.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, fan::FanService}, HapType, Result, }; /// Fan accessory. #[derive(Debug, Default)] pub struct FanAccessory { /// ID of the Fan accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Fan service. pub fan: FanService, } impl FanAccessory { /// Creates a new Fan accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let fan_id = accessory_information.get_characteristics().len() as u64; let mut fan = FanService::new(1 + fan_id + 1, id); fan.set_primary(true); Ok(Self { id, accessory_information, fan, }) } } impl HapAccessory for FanAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.fan, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.fan, ] } } impl Serialize for FanAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/fan_v2.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, fan_v2::FanV2Service}, HapType, Result, }; /// Fan v2 accessory. #[derive(Debug, Default)] pub struct FanV2Accessory { /// ID of the Fan v2 accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Fan v2 service. pub fan_v2: FanV2Service, } impl FanV2Accessory { /// Creates a new Fan v2 accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let fan_v2_id = accessory_information.get_characteristics().len() as u64; let mut fan_v2 = FanV2Service::new(1 + fan_v2_id + 1, id); fan_v2.set_primary(true); Ok(Self { id, accessory_information, fan_v2, }) } } impl HapAccessory for FanV2Accessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.fan_v2, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.fan_v2, ] } } impl Serialize for FanV2Accessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/garage_door_opener.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, garage_door_opener::GarageDoorOpenerService}, HapType, Result, }; /// Garage Door Opener accessory. #[derive(Debug, Default)] pub struct GarageDoorOpenerAccessory { /// ID of the Garage Door Opener accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Garage Door Opener service. pub garage_door_opener: GarageDoorOpenerService, } impl GarageDoorOpenerAccessory { /// Creates a new Garage Door Opener accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let garage_door_opener_id = accessory_information.get_characteristics().len() as u64; let mut garage_door_opener = GarageDoorOpenerService::new(1 + garage_door_opener_id + 1, id); garage_door_opener.set_primary(true); Ok(Self { id, accessory_information, garage_door_opener, }) } } impl HapAccessory for GarageDoorOpenerAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.garage_door_opener, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.garage_door_opener, ] } } impl Serialize for GarageDoorOpenerAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/humidifier_dehumidifier.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, humidifier_dehumidifier::HumidifierDehumidifierService}, HapType, Result, }; /// Humidifier-Dehumidifier accessory. #[derive(Debug, Default)] pub struct HumidifierDehumidifierAccessory { /// ID of the Humidifier-Dehumidifier accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Humidifier-Dehumidifier service. pub humidifier_dehumidifier: HumidifierDehumidifierService, } impl HumidifierDehumidifierAccessory { /// Creates a new Humidifier-Dehumidifier accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let humidifier_dehumidifier_id = accessory_information.get_characteristics().len() as u64; let mut humidifier_dehumidifier = HumidifierDehumidifierService::new(1 + humidifier_dehumidifier_id + 1, id); humidifier_dehumidifier.set_primary(true); Ok(Self { id, accessory_information, humidifier_dehumidifier, }) } } impl HapAccessory for HumidifierDehumidifierAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.humidifier_dehumidifier, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.humidifier_dehumidifier, ] } } impl Serialize for HumidifierDehumidifierAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/humidity_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, humidity_sensor::HumiditySensorService}, HapType, Result, }; /// Humidity Sensor accessory. #[derive(Debug, Default)] pub struct HumiditySensorAccessory { /// ID of the Humidity Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Humidity Sensor service. pub humidity_sensor: HumiditySensorService, } impl HumiditySensorAccessory { /// Creates a new Humidity Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let humidity_sensor_id = accessory_information.get_characteristics().len() as u64; let mut humidity_sensor = HumiditySensorService::new(1 + humidity_sensor_id + 1, id); humidity_sensor.set_primary(true); Ok(Self { id, accessory_information, humidity_sensor, }) } } impl HapAccessory for HumiditySensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.humidity_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.humidity_sensor, ] } } impl Serialize for HumiditySensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/leak_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, leak_sensor::LeakSensorService}, HapType, Result, }; /// Leak Sensor accessory. #[derive(Debug, Default)] pub struct LeakSensorAccessory { /// ID of the Leak Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Leak Sensor service. pub leak_sensor: LeakSensorService, } impl LeakSensorAccessory { /// Creates a new Leak Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let leak_sensor_id = accessory_information.get_characteristics().len() as u64; let mut leak_sensor = LeakSensorService::new(1 + leak_sensor_id + 1, id); leak_sensor.set_primary(true); Ok(Self { id, accessory_information, leak_sensor, }) } } impl HapAccessory for LeakSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.leak_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.leak_sensor, ] } } impl Serialize for LeakSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/light_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, light_sensor::LightSensorService}, HapType, Result, }; /// Light Sensor accessory. #[derive(Debug, Default)] pub struct LightSensorAccessory { /// ID of the Light Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Light Sensor service. pub light_sensor: LightSensorService, } impl LightSensorAccessory { /// Creates a new Light Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let light_sensor_id = accessory_information.get_characteristics().len() as u64; let mut light_sensor = LightSensorService::new(1 + light_sensor_id + 1, id); light_sensor.set_primary(true); Ok(Self { id, accessory_information, light_sensor, }) } } impl HapAccessory for LightSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.light_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.light_sensor, ] } } impl Serialize for LightSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/mod.rs ================================================ // this file is auto-generated by hap-codegen /// Air Purifier accessory definition. pub mod air_purifier; /// Air Quality Sensor accessory definition. pub mod air_quality_sensor; /// Carbon dioxide Sensor accessory definition. pub mod carbon_dioxide_sensor; /// Carbon monoxide Sensor accessory definition. pub mod carbon_monoxide_sensor; /// Contact Sensor accessory definition. pub mod contact_sensor; /// Door accessory definition. pub mod door; /// Fan accessory definition. pub mod fan; /// Fan v2 accessory definition. pub mod fan_v2; /// Garage Door Opener accessory definition. pub mod garage_door_opener; /// Humidifier-Dehumidifier accessory definition. pub mod humidifier_dehumidifier; /// Humidity Sensor accessory definition. pub mod humidity_sensor; /// Leak Sensor accessory definition. pub mod leak_sensor; /// Light Sensor accessory definition. pub mod light_sensor; /// Motion Sensor accessory definition. pub mod motion_sensor; /// Occupancy Sensor accessory definition. pub mod occupancy_sensor; /// Outlet accessory definition. pub mod outlet; /// Security System accessory definition. pub mod security_system; /// Smart Speaker accessory definition. pub mod smart_speaker; /// Smoke Sensor accessory definition. pub mod smoke_sensor; /// Stateful Programmable Switch accessory definition. pub mod stateful_programmable_switch; /// Stateless Programmable Switch accessory definition. pub mod stateless_programmable_switch; /// Switch accessory definition. pub mod switch; /// Temperature Sensor accessory definition. pub mod temperature_sensor; /// Thermostat accessory definition. pub mod thermostat; /// Wi-Fi Router accessory definition. pub mod wi_fi_router; /// Wi-Fi Satellite accessory definition. pub mod wi_fi_satellite; /// Window accessory definition. pub mod window; /// Window Covering accessory definition. pub mod window_covering; ================================================ FILE: src/accessory/generated/motion_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, motion_sensor::MotionSensorService}, HapType, Result, }; /// Motion Sensor accessory. #[derive(Debug, Default)] pub struct MotionSensorAccessory { /// ID of the Motion Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Motion Sensor service. pub motion_sensor: MotionSensorService, } impl MotionSensorAccessory { /// Creates a new Motion Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let motion_sensor_id = accessory_information.get_characteristics().len() as u64; let mut motion_sensor = MotionSensorService::new(1 + motion_sensor_id + 1, id); motion_sensor.set_primary(true); Ok(Self { id, accessory_information, motion_sensor, }) } } impl HapAccessory for MotionSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.motion_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.motion_sensor, ] } } impl Serialize for MotionSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/occupancy_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, occupancy_sensor::OccupancySensorService}, HapType, Result, }; /// Occupancy Sensor accessory. #[derive(Debug, Default)] pub struct OccupancySensorAccessory { /// ID of the Occupancy Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Occupancy Sensor service. pub occupancy_sensor: OccupancySensorService, } impl OccupancySensorAccessory { /// Creates a new Occupancy Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let occupancy_sensor_id = accessory_information.get_characteristics().len() as u64; let mut occupancy_sensor = OccupancySensorService::new(1 + occupancy_sensor_id + 1, id); occupancy_sensor.set_primary(true); Ok(Self { id, accessory_information, occupancy_sensor, }) } } impl HapAccessory for OccupancySensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.occupancy_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.occupancy_sensor, ] } } impl Serialize for OccupancySensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/outlet.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, outlet::OutletService}, HapType, Result, }; /// Outlet accessory. #[derive(Debug, Default)] pub struct OutletAccessory { /// ID of the Outlet accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Outlet service. pub outlet: OutletService, } impl OutletAccessory { /// Creates a new Outlet accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let outlet_id = accessory_information.get_characteristics().len() as u64; let mut outlet = OutletService::new(1 + outlet_id + 1, id); outlet.set_primary(true); Ok(Self { id, accessory_information, outlet, }) } } impl HapAccessory for OutletAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.outlet, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.outlet, ] } } impl Serialize for OutletAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/security_system.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, security_system::SecuritySystemService}, HapType, Result, }; /// Security System accessory. #[derive(Debug, Default)] pub struct SecuritySystemAccessory { /// ID of the Security System accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Security System service. pub security_system: SecuritySystemService, } impl SecuritySystemAccessory { /// Creates a new Security System accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let security_system_id = accessory_information.get_characteristics().len() as u64; let mut security_system = SecuritySystemService::new(1 + security_system_id + 1, id); security_system.set_primary(true); Ok(Self { id, accessory_information, security_system, }) } } impl HapAccessory for SecuritySystemAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.security_system, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.security_system, ] } } impl Serialize for SecuritySystemAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/smart_speaker.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, smart_speaker::SmartSpeakerService}, HapType, Result, }; /// Smart Speaker accessory. #[derive(Debug, Default)] pub struct SmartSpeakerAccessory { /// ID of the Smart Speaker accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Smart Speaker service. pub smart_speaker: SmartSpeakerService, } impl SmartSpeakerAccessory { /// Creates a new Smart Speaker accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let smart_speaker_id = accessory_information.get_characteristics().len() as u64; let mut smart_speaker = SmartSpeakerService::new(1 + smart_speaker_id + 1, id); smart_speaker.set_primary(true); Ok(Self { id, accessory_information, smart_speaker, }) } } impl HapAccessory for SmartSpeakerAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.smart_speaker, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.smart_speaker, ] } } impl Serialize for SmartSpeakerAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/smoke_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, smoke_sensor::SmokeSensorService}, HapType, Result, }; /// Smoke Sensor accessory. #[derive(Debug, Default)] pub struct SmokeSensorAccessory { /// ID of the Smoke Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Smoke Sensor service. pub smoke_sensor: SmokeSensorService, } impl SmokeSensorAccessory { /// Creates a new Smoke Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let smoke_sensor_id = accessory_information.get_characteristics().len() as u64; let mut smoke_sensor = SmokeSensorService::new(1 + smoke_sensor_id + 1, id); smoke_sensor.set_primary(true); Ok(Self { id, accessory_information, smoke_sensor, }) } } impl HapAccessory for SmokeSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.smoke_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.smoke_sensor, ] } } impl Serialize for SmokeSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/stateful_programmable_switch.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, stateful_programmable_switch::StatefulProgrammableSwitchService}, HapType, Result, }; /// Stateful Programmable Switch accessory. #[derive(Debug, Default)] pub struct StatefulProgrammableSwitchAccessory { /// ID of the Stateful Programmable Switch accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Stateful Programmable Switch service. pub stateful_programmable_switch: StatefulProgrammableSwitchService, } impl StatefulProgrammableSwitchAccessory { /// Creates a new Stateful Programmable Switch accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let stateful_programmable_switch_id = accessory_information.get_characteristics().len() as u64; let mut stateful_programmable_switch = StatefulProgrammableSwitchService::new(1 + stateful_programmable_switch_id + 1, id); stateful_programmable_switch.set_primary(true); Ok(Self { id, accessory_information, stateful_programmable_switch, }) } } impl HapAccessory for StatefulProgrammableSwitchAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.stateful_programmable_switch, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.stateful_programmable_switch, ] } } impl Serialize for StatefulProgrammableSwitchAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/stateless_programmable_switch.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, stateless_programmable_switch::StatelessProgrammableSwitchService}, HapType, Result, }; /// Stateless Programmable Switch accessory. #[derive(Debug, Default)] pub struct StatelessProgrammableSwitchAccessory { /// ID of the Stateless Programmable Switch accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Stateless Programmable Switch service. pub stateless_programmable_switch: StatelessProgrammableSwitchService, } impl StatelessProgrammableSwitchAccessory { /// Creates a new Stateless Programmable Switch accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let stateless_programmable_switch_id = accessory_information.get_characteristics().len() as u64; let mut stateless_programmable_switch = StatelessProgrammableSwitchService::new(1 + stateless_programmable_switch_id + 1, id); stateless_programmable_switch.set_primary(true); Ok(Self { id, accessory_information, stateless_programmable_switch, }) } } impl HapAccessory for StatelessProgrammableSwitchAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.stateless_programmable_switch, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.stateless_programmable_switch, ] } } impl Serialize for StatelessProgrammableSwitchAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/switch.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, switch::SwitchService}, HapType, Result, }; /// Switch accessory. #[derive(Debug, Default)] pub struct SwitchAccessory { /// ID of the Switch accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Switch service. pub switch: SwitchService, } impl SwitchAccessory { /// Creates a new Switch accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let switch_id = accessory_information.get_characteristics().len() as u64; let mut switch = SwitchService::new(1 + switch_id + 1, id); switch.set_primary(true); Ok(Self { id, accessory_information, switch, }) } } impl HapAccessory for SwitchAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.switch, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.switch, ] } } impl Serialize for SwitchAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/temperature_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, temperature_sensor::TemperatureSensorService}, HapType, Result, }; /// Temperature Sensor accessory. #[derive(Debug, Default)] pub struct TemperatureSensorAccessory { /// ID of the Temperature Sensor accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Temperature Sensor service. pub temperature_sensor: TemperatureSensorService, } impl TemperatureSensorAccessory { /// Creates a new Temperature Sensor accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let temperature_sensor_id = accessory_information.get_characteristics().len() as u64; let mut temperature_sensor = TemperatureSensorService::new(1 + temperature_sensor_id + 1, id); temperature_sensor.set_primary(true); Ok(Self { id, accessory_information, temperature_sensor, }) } } impl HapAccessory for TemperatureSensorAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.temperature_sensor, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.temperature_sensor, ] } } impl Serialize for TemperatureSensorAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/thermostat.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, thermostat::ThermostatService}, HapType, Result, }; /// Thermostat accessory. #[derive(Debug, Default)] pub struct ThermostatAccessory { /// ID of the Thermostat accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Thermostat service. pub thermostat: ThermostatService, } impl ThermostatAccessory { /// Creates a new Thermostat accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let thermostat_id = accessory_information.get_characteristics().len() as u64; let mut thermostat = ThermostatService::new(1 + thermostat_id + 1, id); thermostat.set_primary(true); Ok(Self { id, accessory_information, thermostat, }) } } impl HapAccessory for ThermostatAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.thermostat, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.thermostat, ] } } impl Serialize for ThermostatAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/wi_fi_router.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, wi_fi_router::WiFiRouterService}, HapType, Result, }; /// Wi-Fi Router accessory. #[derive(Debug, Default)] pub struct WiFiRouterAccessory { /// ID of the Wi-Fi Router accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Wi-Fi Router service. pub wi_fi_router: WiFiRouterService, } impl WiFiRouterAccessory { /// Creates a new Wi-Fi Router accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let wi_fi_router_id = accessory_information.get_characteristics().len() as u64; let mut wi_fi_router = WiFiRouterService::new(1 + wi_fi_router_id + 1, id); wi_fi_router.set_primary(true); Ok(Self { id, accessory_information, wi_fi_router, }) } } impl HapAccessory for WiFiRouterAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.wi_fi_router, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.wi_fi_router, ] } } impl Serialize for WiFiRouterAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/wi_fi_satellite.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, wi_fi_satellite::WiFiSatelliteService}, HapType, Result, }; /// Wi-Fi Satellite accessory. #[derive(Debug, Default)] pub struct WiFiSatelliteAccessory { /// ID of the Wi-Fi Satellite accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Wi-Fi Satellite service. pub wi_fi_satellite: WiFiSatelliteService, } impl WiFiSatelliteAccessory { /// Creates a new Wi-Fi Satellite accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let wi_fi_satellite_id = accessory_information.get_characteristics().len() as u64; let mut wi_fi_satellite = WiFiSatelliteService::new(1 + wi_fi_satellite_id + 1, id); wi_fi_satellite.set_primary(true); Ok(Self { id, accessory_information, wi_fi_satellite, }) } } impl HapAccessory for WiFiSatelliteAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.wi_fi_satellite, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.wi_fi_satellite, ] } } impl Serialize for WiFiSatelliteAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/window.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, window::WindowService}, HapType, Result, }; /// Window accessory. #[derive(Debug, Default)] pub struct WindowAccessory { /// ID of the Window accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Window service. pub window: WindowService, } impl WindowAccessory { /// Creates a new Window accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let window_id = accessory_information.get_characteristics().len() as u64; let mut window = WindowService::new(1 + window_id + 1, id); window.set_primary(true); Ok(Self { id, accessory_information, window, }) } } impl HapAccessory for WindowAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.window, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.window, ] } } impl Serialize for WindowAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/generated/window_covering.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ accessory::{AccessoryInformation, HapAccessory}, service::{HapService, accessory_information::AccessoryInformationService, window_covering::WindowCoveringService}, HapType, Result, }; /// Window Covering accessory. #[derive(Debug, Default)] pub struct WindowCoveringAccessory { /// ID of the Window Covering accessory. id: u64, /// Accessory Information service. pub accessory_information: AccessoryInformationService, /// Window Covering service. pub window_covering: WindowCoveringService, } impl WindowCoveringAccessory { /// Creates a new Window Covering accessory. pub fn new(id: u64, information: AccessoryInformation) -> Result { let accessory_information = information.to_service(1, id)?; let window_covering_id = accessory_information.get_characteristics().len() as u64; let mut window_covering = WindowCoveringService::new(1 + window_covering_id + 1, id); window_covering.set_primary(true); Ok(Self { id, accessory_information, window_covering, }) } } impl HapAccessory for WindowCoveringAccessory { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService> { for service in self.get_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService> { for service in self.get_mut_services() { if service.get_type() == hap_type { return Some(service); } } None } fn get_services(&self) -> Vec<&dyn HapService> { vec![ &self.accessory_information, &self.window_covering, ] } fn get_mut_services(&mut self) -> Vec<&mut dyn HapService> { vec![ &mut self.accessory_information, &mut self.window_covering, ] } } impl Serialize for WindowCoveringAccessory { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("HapAccessory", 2)?; state.serialize_field("aid", &self.get_id())?; state.serialize_field("services", &self.get_services())?; state.end() } } ================================================ FILE: src/accessory/mod.rs ================================================ use erased_serde::serialize_trait_object; use futures::executor; use crate::{ characteristic::{ accessory_flags::AccessoryFlagsCharacteristic, application_matching_identifier::ApplicationMatchingIdentifierCharacteristic, configured_name::ConfiguredNameCharacteristic, firmware_revision::FirmwareRevisionCharacteristic, hardware_finish::HardwareFinishCharacteristic, hardware_revision::HardwareRevisionCharacteristic, product_data::ProductDataCharacteristic, software_revision::SoftwareRevisionCharacteristic, HapCharacteristic, }, pointer, service::{accessory_information::AccessoryInformationService, HapService}, HapType, Result, }; mod category; mod defined; mod generated; pub use crate::accessory::{category::AccessoryCategory, defined::*, generated::*}; /// [`HapAccessory`](HapAccessory) is implemented by every HAP accessory. pub trait HapAccessory: HapAccessorySetup + erased_serde::Serialize + Send + Sync { /// Returns the ID of the accessory. fn get_id(&self) -> u64; /// Sets the ID of the accessory. fn set_id(&mut self, id: u64); /// Returns a reference to a specific service of the accessory if it's present on it. fn get_service(&self, hap_type: HapType) -> Option<&dyn HapService>; /// Returns a mutable reference to a specific service of the accessory if it's present on it. fn get_mut_service(&mut self, hap_type: HapType) -> Option<&mut dyn HapService>; /// Returns references to all services of the accessory. fn get_services(&self) -> Vec<&dyn HapService>; /// Returns mutable references to all services of the accessory. fn get_mut_services(&mut self) -> Vec<&mut dyn HapService>; } serialize_trait_object!(HapAccessory); /// [`HapAccessorySetup`](HapAccessorySetup) is implemented by every HAP accessory to provide helper methods used by the /// HAP server for setup purposes. It's not meant to be used by a consumer of the library. pub trait HapAccessorySetup { /// Sets a pointer to an `EventEmitter` on all characteristics of the accessory. fn set_event_emitter_on_characteristics(&mut self, event_emitter: Option); } impl HapAccessorySetup for H where H: HapAccessory, { fn set_event_emitter_on_characteristics(&mut self, event_emitter: Option) { for service in self.get_mut_services() { for characteristic in service.get_mut_characteristics() { characteristic.set_event_emitter(event_emitter.clone()); } } } } /// The [`AccessoryInformation`](AccessoryInformation) struct is used to conveniently store metadata about an accessory /// and is converted to the [`AccessoryInformationService`](AccessoryInformationService) of the accessory it is passed /// to on its creation. /// /// # Examples /// /// ``` /// use hap::accessory::{outlet::OutletAccessory, AccessoryInformation}; /// /// let information = AccessoryInformation { /// manufacturer: "Acme".into(), /// model: "A1234".into(), /// name: "Acme Outlet".into(), /// serial_number: "1A2B3C4D5E6F".into(), /// ..Default::default() /// }; /// /// let outlet = OutletAccessory::new(1, information).unwrap(); /// ``` #[derive(Debug)] pub struct AccessoryInformation { // TODO - include all possible fields of AccessoryInformationService /// Contains the name of the company whose brand will appear on the accessory, e.g., "Acme". pub manufacturer: String, /// Contains the manufacturer-specific model of the accessory, e.g. "A1234". pub model: String, /// Describes the name of the accessory. pub name: String, /// Contains the manufacturer-specific serial number of the accessory, e.g. "1A2B3C4D5E6F". /// The length must be greater than 1. pub serial_number: String, /// When set indicates accessory requires additional setup. Use of accessory flags requires /// written approval by Apple in advance. pub accessory_flags: Option, pub application_matching_identifier: Option>, pub configured_name: Option, /// Describes a firmware revision string x[.y[.z]] (e.g. "100.1.1"): /// - is the major version number, required. /// - is the minor version number, required if it is non-zero or if is present. /// - is the revision version number, required if non-zero. /// /// The firmware revision must follow the below rules: /// - is incremented when there is significant change. e.g., 1.0.0, 2.0.0, 3.0.0, etc. /// - is incremented when minor changes are introduced such as 1.1.0, 2.1.0, 3.1.0 etc. /// - is incremented when bug-fixes are introduced such as 1.0.1, 2.0.1, 3.0.1 etc. /// - Subsequent firmware updates can have a lower version only if is incremented /// - Subsequent firmware updates can have a lower version only if or is incremented /// /// The value must change after every firmware update. pub firmware_revision: Option, pub hardware_finish: Option>, /// Describes a hardware revision string x[.y[.z]] (e.g. "100.1.1") and tracked when the board /// or components of the same accessory is changed: /// - is the major version number, required. /// - is the minor version number, required if it is non-zero or if is present. /// - is the revision version number, required if non-zero. /// /// The hardware revision must follow the below rules: /// - is incremented when there is significant change. e.g., 1.0.0, 2.0.0, 3.0.0, etc. /// - is incremented when minor changes are introduced such as 1.1.0, 2.1.0, 3.1.0 etc. /// - is incremented when bug-fixes are introduced such as 1.0.1, 2.0.1, 3.0.1 etc. /// - Subsequent firmware updates can have a lower version only if is incremented /// - Subsequent firmware updates can have a lower version only if or is incremented /// /// The value must change after every hardware update. pub hardware_revision: Option, pub product_data: Option>, pub software_revision: Option, } impl AccessoryInformation { /// Converts the `Information` struct to an Accessory Information Service. pub fn to_service(self, id: u64, accessory_id: u64) -> Result { let mut i = AccessoryInformationService::new(id, accessory_id); executor::block_on(i.identify.set_value(serde_json::Value::Bool(false)))?; executor::block_on(i.manufacturer.set_value(serde_json::Value::String(self.manufacturer)))?; executor::block_on(i.model.set_value(serde_json::Value::String(self.model)))?; executor::block_on(i.name.set_value(serde_json::Value::String(self.name)))?; executor::block_on(i.serial_number.set_value(serde_json::Value::String(self.serial_number)))?; if let Some(v) = self.accessory_flags { let mut c = AccessoryFlagsCharacteristic::new(id + 6, accessory_id); executor::block_on(c.set_value(v.into()))?; i.accessory_flags = Some(c); } else { i.accessory_flags = None; } if let Some(v) = self.application_matching_identifier { let mut c = ApplicationMatchingIdentifierCharacteristic::new(id + 7, accessory_id); executor::block_on(c.set_value(v.into()))?; i.application_matching_identifier = Some(c); } else { i.application_matching_identifier = None; } if let Some(v) = self.configured_name { let mut c = ConfiguredNameCharacteristic::new(id + 8, accessory_id); executor::block_on(c.set_value(v.into()))?; i.configured_name = Some(c); } else { i.configured_name = None; } if let Some(v) = self.firmware_revision { let mut c = FirmwareRevisionCharacteristic::new(id + 9, accessory_id); executor::block_on(c.set_value(v.into()))?; i.firmware_revision = Some(c); } else { i.firmware_revision = None; } if let Some(v) = self.hardware_finish { let mut c = HardwareFinishCharacteristic::new(id + 12, accessory_id); executor::block_on(c.set_value(v.into()))?; i.hardware_finish = Some(c); } else { i.hardware_finish = None; } if let Some(v) = self.hardware_revision { let mut c = HardwareRevisionCharacteristic::new(id + 10, accessory_id); executor::block_on(c.set_value(v.into()))?; i.hardware_revision = Some(c); } else { i.hardware_revision = None; } if let Some(v) = self.product_data { let mut c = ProductDataCharacteristic::new(id + 12, accessory_id); executor::block_on(c.set_value(v.into()))?; i.product_data = Some(c); } else { i.product_data = None; } if let Some(v) = self.software_revision { let mut c = SoftwareRevisionCharacteristic::new(id + 11, accessory_id); executor::block_on(c.set_value(v.into()))?; i.software_revision = Some(c); } else { i.software_revision = None; } Ok(i) } } impl Default for AccessoryInformation { fn default() -> Self { Self { manufacturer: "undefined".into(), model: "undefined".into(), name: "undefined".into(), serial_number: "undefined".into(), accessory_flags: None, application_matching_identifier: None, configured_name: None, firmware_revision: None, hardware_finish: None, hardware_revision: None, product_data: None, software_revision: None, } } } ================================================ FILE: src/characteristic/generated/access_code_control_point.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Access Code Control Point characteristic. #[derive(Debug, Default, Serialize)] pub struct AccessCodeControlPointCharacteristic(Characteristic>); impl AccessCodeControlPointCharacteristic { /// Creates a new Access Code Control Point characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::AccessCodeControlPoint, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AccessCodeControlPointCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AccessCodeControlPointCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for AccessCodeControlPointCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for AccessCodeControlPointCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/access_code_supported_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Access Code Supported Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct AccessCodeSupportedConfigurationCharacteristic(Characteristic>); impl AccessCodeSupportedConfigurationCharacteristic { /// Creates a new Access Code Supported Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::AccessCodeSupportedConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AccessCodeSupportedConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AccessCodeSupportedConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for AccessCodeSupportedConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for AccessCodeSupportedConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/access_control_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Access Control Level characteristic. #[derive(Debug, Default, Serialize)] pub struct AccessControlLevelCharacteristic(Characteristic); impl AccessControlLevelCharacteristic { /// Creates a new Access Control Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AccessControlLevel, format: Format::UInt16, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AccessControlLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AccessControlLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AccessControlLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AccessControlLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/accessory_flags.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Accessory Flags characteristic. #[derive(Debug, Default, Serialize)] pub struct AccessoryFlagsCharacteristic(Characteristic); impl AccessoryFlagsCharacteristic { /// Creates a new Accessory Flags characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AccessoryFlags, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AccessoryFlagsCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AccessoryFlagsCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AccessoryFlagsCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AccessoryFlagsCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/accessory_identifier.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Accessory Identifier characteristic. #[derive(Debug, Default, Serialize)] pub struct AccessoryIdentifierCharacteristic(Characteristic); impl AccessoryIdentifierCharacteristic { /// Creates a new Accessory Identifier characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AccessoryIdentifier, format: Format::String, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AccessoryIdentifierCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AccessoryIdentifierCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AccessoryIdentifierCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AccessoryIdentifierCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/active.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Active characteristic. #[derive(Debug, Default, Serialize)] pub struct ActiveCharacteristic(Characteristic); impl ActiveCharacteristic { /// Creates a new Active characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Active, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ActiveCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ActiveCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ActiveCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ActiveCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/active_identifier.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Active Identifier characteristic. #[derive(Debug, Default, Serialize)] pub struct ActiveIdentifierCharacteristic(Characteristic); impl ActiveIdentifierCharacteristic { /// Creates a new Active Identifier characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ActiveIdentifier, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ActiveIdentifierCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ActiveIdentifierCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ActiveIdentifierCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ActiveIdentifierCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/activity_interval.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Activity Interval characteristic. #[derive(Debug, Default, Serialize)] pub struct ActivityIntervalCharacteristic(Characteristic); impl ActivityIntervalCharacteristic { /// Creates a new Activity Interval characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ActivityInterval, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, ], min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ActivityIntervalCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ActivityIntervalCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ActivityIntervalCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ActivityIntervalCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/administrator_only_access.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Administrator Only Access characteristic. #[derive(Debug, Default, Serialize)] pub struct AdministratorOnlyAccessCharacteristic(Characteristic); impl AdministratorOnlyAccessCharacteristic { /// Creates a new Administrator Only Access characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AdministratorOnlyAccess, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AdministratorOnlyAccessCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AdministratorOnlyAccessCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AdministratorOnlyAccessCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AdministratorOnlyAccessCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/air_particulate_density.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Air Particulate Density characteristic. #[derive(Debug, Default, Serialize)] pub struct AirParticulateDensityCharacteristic(Characteristic); impl AirParticulateDensityCharacteristic { /// Creates a new Air Particulate Density characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AirParticulateDensity, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::MicrogramsPerCubicMeter), max_value: Some(1000 as f32), min_value: Some(0 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AirParticulateDensityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AirParticulateDensityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AirParticulateDensityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AirParticulateDensityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/air_particulate_size.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Air Particulate Size characteristic. #[derive(Debug, Default, Serialize)] pub struct AirParticulateSizeCharacteristic(Characteristic); impl AirParticulateSizeCharacteristic { /// Creates a new Air Particulate Size characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AirParticulateSize, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AirParticulateSizeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AirParticulateSizeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AirParticulateSizeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AirParticulateSizeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/airplay_enable.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// AirPlay Enable characteristic. #[derive(Debug, Default, Serialize)] pub struct AirplayEnableCharacteristic(Characteristic); impl AirplayEnableCharacteristic { /// Creates a new AirPlay Enable characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AirplayEnable, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AirplayEnableCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AirplayEnableCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AirplayEnableCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AirplayEnableCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/application_matching_identifier.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Application Matching Identifier characteristic. #[derive(Debug, Default, Serialize)] pub struct ApplicationMatchingIdentifierCharacteristic(Characteristic>); impl ApplicationMatchingIdentifierCharacteristic { /// Creates a new Application Matching Identifier characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::ApplicationMatchingIdentifier, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ApplicationMatchingIdentifierCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ApplicationMatchingIdentifierCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for ApplicationMatchingIdentifierCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for ApplicationMatchingIdentifierCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/asset_update_readiness.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Asset Update Readiness characteristic. #[derive(Debug, Default, Serialize)] pub struct AssetUpdateReadinessCharacteristic(Characteristic); impl AssetUpdateReadinessCharacteristic { /// Creates a new Asset Update Readiness characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AssetUpdateReadiness, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AssetUpdateReadinessCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AssetUpdateReadinessCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AssetUpdateReadinessCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AssetUpdateReadinessCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/audio_feedback.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Audio Feedback characteristic. #[derive(Debug, Default, Serialize)] pub struct AudioFeedbackCharacteristic(Characteristic); impl AudioFeedbackCharacteristic { /// Creates a new Audio Feedback characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::AudioFeedback, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for AudioFeedbackCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for AudioFeedbackCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for AudioFeedbackCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for AudioFeedbackCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/battery_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Battery Level characteristic. #[derive(Debug, Default, Serialize)] pub struct BatteryLevelCharacteristic(Characteristic); impl BatteryLevelCharacteristic { /// Creates a new Battery Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::BatteryLevel, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::Percentage), max_value: Some(100), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for BatteryLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for BatteryLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for BatteryLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for BatteryLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/brightness.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Brightness characteristic. #[derive(Debug, Default, Serialize)] pub struct BrightnessCharacteristic(Characteristic); impl BrightnessCharacteristic { /// Creates a new Brightness characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Brightness, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Percentage), max_value: Some(100), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for BrightnessCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for BrightnessCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for BrightnessCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for BrightnessCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/button_event.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Button Event characteristic. #[derive(Debug, Default, Serialize)] pub struct ButtonEventCharacteristic(Characteristic>); impl ButtonEventCharacteristic { /// Creates a new Button Event characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::ButtonEvent, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ButtonEventCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ButtonEventCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for ButtonEventCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for ButtonEventCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/camera_operating_mode_indicator.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Camera Operating Mode Indicator characteristic. #[derive(Debug, Default, Serialize)] pub struct CameraOperatingModeIndicatorCharacteristic(Characteristic); impl CameraOperatingModeIndicatorCharacteristic { /// Creates a new Camera Operating Mode Indicator characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CameraOperatingModeIndicator, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CameraOperatingModeIndicatorCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CameraOperatingModeIndicatorCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CameraOperatingModeIndicatorCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CameraOperatingModeIndicatorCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/carbon_dioxide_detected.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Carbon dioxide Detected characteristic. #[derive(Debug, Default, Serialize)] pub struct CarbonDioxideDetectedCharacteristic(Characteristic); pub enum Value { Normal = 0, Abnormal = 1, } impl CarbonDioxideDetectedCharacteristic { /// Creates a new Carbon dioxide Detected characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CarbonDioxideDetected, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // NORMAL 1, // ABNORMAL ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CarbonDioxideDetectedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CarbonDioxideDetectedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CarbonDioxideDetectedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CarbonDioxideDetectedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/carbon_dioxide_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Carbon dioxide Level characteristic. #[derive(Debug, Default, Serialize)] pub struct CarbonDioxideLevelCharacteristic(Characteristic); impl CarbonDioxideLevelCharacteristic { /// Creates a new Carbon dioxide Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CarbonDioxideLevel, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::PartsPerMillion), max_value: Some(100000 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CarbonDioxideLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CarbonDioxideLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CarbonDioxideLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CarbonDioxideLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/carbon_dioxide_peak_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Carbon dioxide Peak Level characteristic. #[derive(Debug, Default, Serialize)] pub struct CarbonDioxidePeakLevelCharacteristic(Characteristic); impl CarbonDioxidePeakLevelCharacteristic { /// Creates a new Carbon dioxide Peak Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CarbonDioxidePeakLevel, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::PartsPerMillion), max_value: Some(100000 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CarbonDioxidePeakLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CarbonDioxidePeakLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CarbonDioxidePeakLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CarbonDioxidePeakLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/carbon_monoxide_detected.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Carbon monoxide Detected characteristic. #[derive(Debug, Default, Serialize)] pub struct CarbonMonoxideDetectedCharacteristic(Characteristic); impl CarbonMonoxideDetectedCharacteristic { /// Creates a new Carbon monoxide Detected characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CarbonMonoxideDetected, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CarbonMonoxideDetectedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CarbonMonoxideDetectedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CarbonMonoxideDetectedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CarbonMonoxideDetectedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/carbon_monoxide_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Carbon monoxide Level characteristic. #[derive(Debug, Default, Serialize)] pub struct CarbonMonoxideLevelCharacteristic(Characteristic); impl CarbonMonoxideLevelCharacteristic { /// Creates a new Carbon monoxide Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CarbonMonoxideLevel, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::PartsPerMillion), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CarbonMonoxideLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CarbonMonoxideLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CarbonMonoxideLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CarbonMonoxideLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/carbon_monoxide_peak_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Carbon monoxide Peak Level characteristic. #[derive(Debug, Default, Serialize)] pub struct CarbonMonoxidePeakLevelCharacteristic(Characteristic); impl CarbonMonoxidePeakLevelCharacteristic { /// Creates a new Carbon monoxide Peak Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CarbonMonoxidePeakLevel, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::PartsPerMillion), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CarbonMonoxidePeakLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CarbonMonoxidePeakLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CarbonMonoxidePeakLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CarbonMonoxidePeakLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/cca_energy_detect_threshold.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// CCA Energy Detect Threshold characteristic. #[derive(Debug, Default, Serialize)] pub struct CcaEnergyDetectThresholdCharacteristic(Characteristic); impl CcaEnergyDetectThresholdCharacteristic { /// Creates a new CCA Energy Detect Threshold characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CcaEnergyDetectThreshold, format: Format::Int32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CcaEnergyDetectThresholdCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CcaEnergyDetectThresholdCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CcaEnergyDetectThresholdCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CcaEnergyDetectThresholdCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/cca_signal_detect_threshold.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// CCA Signal Detect Threshold characteristic. #[derive(Debug, Default, Serialize)] pub struct CcaSignalDetectThresholdCharacteristic(Characteristic); impl CcaSignalDetectThresholdCharacteristic { /// Creates a new CCA Signal Detect Threshold characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CcaSignalDetectThreshold, format: Format::Int32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CcaSignalDetectThresholdCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CcaSignalDetectThresholdCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CcaSignalDetectThresholdCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CcaSignalDetectThresholdCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/characteristic_value_active_transition_count.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Characteristic Value Active Transition Count characteristic. #[derive(Debug, Default, Serialize)] pub struct CharacteristicValueActiveTransitionCountCharacteristic(Characteristic); impl CharacteristicValueActiveTransitionCountCharacteristic { /// Creates a new Characteristic Value Active Transition Count characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CharacteristicValueActiveTransitionCount, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CharacteristicValueActiveTransitionCountCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CharacteristicValueActiveTransitionCountCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CharacteristicValueActiveTransitionCountCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CharacteristicValueActiveTransitionCountCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/characteristic_value_transition_control.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Characteristic Value Transition Control characteristic. #[derive(Debug, Default, Serialize)] pub struct CharacteristicValueTransitionControlCharacteristic(Characteristic>); impl CharacteristicValueTransitionControlCharacteristic { /// Creates a new Characteristic Value Transition Control characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::CharacteristicValueTransitionControl, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CharacteristicValueTransitionControlCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CharacteristicValueTransitionControlCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for CharacteristicValueTransitionControlCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for CharacteristicValueTransitionControlCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/charging_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Charging State characteristic. #[derive(Debug, Default, Serialize)] pub struct ChargingStateCharacteristic(Characteristic); pub enum Value { NotCharging = 0, Charging = 1, NotChargeable = 2, } impl ChargingStateCharacteristic { /// Creates a new Charging State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ChargingState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // NOT_CHARGING 1, // CHARGING 2, // NOT_CHARGEABLE ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ChargingStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ChargingStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ChargingStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ChargingStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/closed_captions.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Closed Captions characteristic. #[derive(Debug, Default, Serialize)] pub struct ClosedCaptionsCharacteristic(Characteristic); impl ClosedCaptionsCharacteristic { /// Creates a new Closed Captions characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ClosedCaptions, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ClosedCaptionsCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ClosedCaptionsCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ClosedCaptionsCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ClosedCaptionsCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/cloud_relay_control_point.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Cloud Relay Control Point characteristic. #[derive(Debug, Default, Serialize)] pub struct CloudRelayControlPointCharacteristic(Characteristic>); impl CloudRelayControlPointCharacteristic { /// Creates a new Cloud Relay Control Point characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::CloudRelayControlPoint, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CloudRelayControlPointCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CloudRelayControlPointCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for CloudRelayControlPointCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for CloudRelayControlPointCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/cloud_relay_current_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Cloud Relay Current State characteristic. #[derive(Debug, Default, Serialize)] pub struct CloudRelayCurrentStateCharacteristic(Characteristic); impl CloudRelayCurrentStateCharacteristic { /// Creates a new Cloud Relay Current State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CloudRelayCurrentState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(5), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CloudRelayCurrentStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CloudRelayCurrentStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CloudRelayCurrentStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CloudRelayCurrentStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/cloud_relay_enable_status.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Cloud Relay Enable Status characteristic. #[derive(Debug, Default, Serialize)] pub struct CloudRelayEnableStatusCharacteristic(Characteristic); impl CloudRelayEnableStatusCharacteristic { /// Creates a new Cloud Relay Enable Status characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CloudRelayEnableStatus, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CloudRelayEnableStatusCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CloudRelayEnableStatusCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CloudRelayEnableStatusCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CloudRelayEnableStatusCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/color_temperature.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Color Temperature characteristic. #[derive(Debug, Default, Serialize)] pub struct ColorTemperatureCharacteristic(Characteristic); impl ColorTemperatureCharacteristic { /// Creates a new Color Temperature characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ColorTemperature, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(500), min_value: Some(140), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ColorTemperatureCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ColorTemperatureCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ColorTemperatureCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ColorTemperatureCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/configuration_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Configuration State characteristic. #[derive(Debug, Default, Serialize)] pub struct ConfigurationStateCharacteristic(Characteristic); impl ConfigurationStateCharacteristic { /// Creates a new Configuration State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ConfigurationState, format: Format::UInt16, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ConfigurationStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ConfigurationStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ConfigurationStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ConfigurationStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/configured_name.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Configured Name characteristic. #[derive(Debug, Default, Serialize)] pub struct ConfiguredNameCharacteristic(Characteristic); impl ConfiguredNameCharacteristic { /// Creates a new Configured Name characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ConfiguredName, format: Format::String, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ConfiguredNameCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ConfiguredNameCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ConfiguredNameCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ConfiguredNameCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/contact_sensor_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Contact Sensor State characteristic. #[derive(Debug, Default, Serialize)] pub struct ContactSensorStateCharacteristic(Characteristic); pub enum Value { Num0 = 0, Num1 = 1, } impl ContactSensorStateCharacteristic { /// Creates a new Contact Sensor State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ContactSensorState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // 0 1, // 1 ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ContactSensorStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ContactSensorStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ContactSensorStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ContactSensorStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/cooling_threshold_temperature.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Cooling Threshold Temperature characteristic. #[derive(Debug, Default, Serialize)] pub struct CoolingThresholdTemperatureCharacteristic(Characteristic); impl CoolingThresholdTemperatureCharacteristic { /// Creates a new Cooling Threshold Temperature characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CoolingThresholdTemperature, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Celsius), max_value: Some(35 as f32), min_value: Some(10 as f32), step_value: Some(0.1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CoolingThresholdTemperatureCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CoolingThresholdTemperatureCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CoolingThresholdTemperatureCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CoolingThresholdTemperatureCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_air_purifier_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Air Purifier State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentAirPurifierStateCharacteristic(Characteristic); pub enum Value { Inactive = 0, Idle = 1, PurifyingAir = 2, } impl CurrentAirPurifierStateCharacteristic { /// Creates a new Current Air Purifier State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentAirPurifierState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // INACTIVE 1, // IDLE 2, // PURIFYING_AIR ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentAirPurifierStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentAirPurifierStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentAirPurifierStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentAirPurifierStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_air_quality.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Air Quality characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentAirQualityCharacteristic(Characteristic); pub enum Value { Unknown = 0, Excellent = 1, Good = 2, Fair = 3, Inferior = 4, Poor = 5, } impl CurrentAirQualityCharacteristic { /// Creates a new Current Air Quality characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentAirQuality, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(5), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // UNKNOWN 1, // EXCELLENT 2, // GOOD 3, // FAIR 4, // INFERIOR 5, // POOR ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentAirQualityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentAirQualityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentAirQualityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentAirQualityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_door_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Door State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentDoorStateCharacteristic(Characteristic); pub enum Value { Num1 = 0, Num0 = 1, Num2 = 2, Num3 = 3, Num4 = 4, } impl CurrentDoorStateCharacteristic { /// Creates a new Current Door State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentDoorState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(4), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // 1 1, // 0 2, // 2 3, // 3 4, // 4 ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentDoorStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentDoorStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentDoorStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentDoorStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_fan_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Fan State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentFanStateCharacteristic(Characteristic); pub enum Value { Inactive = 0, Idle = 1, Blowing = 2, } impl CurrentFanStateCharacteristic { /// Creates a new Current Fan State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentFanState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // INACTIVE 1, // IDLE 2, // BLOWING ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentFanStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentFanStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentFanStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentFanStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_heater_cooler_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Heater-Cooler State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentHeaterCoolerStateCharacteristic(Characteristic); pub enum Value { Inactive = 0, Idle = 1, Heating = 2, Cooling = 3, } impl CurrentHeaterCoolerStateCharacteristic { /// Creates a new Current Heater-Cooler State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentHeaterCoolerState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // INACTIVE 1, // IDLE 2, // HEATING 3, // COOLING ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentHeaterCoolerStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentHeaterCoolerStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentHeaterCoolerStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentHeaterCoolerStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_heating_cooling_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Heating Cooling State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentHeatingCoolingStateCharacteristic(Characteristic); pub enum Value { Off = 0, Heat = 1, Cool = 2, Auto = 3, } impl CurrentHeatingCoolingStateCharacteristic { /// Creates a new Current Heating Cooling State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentHeatingCoolingState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // OFF 1, // HEAT 2, // COOL 3, // AUTO ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentHeatingCoolingStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentHeatingCoolingStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentHeatingCoolingStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentHeatingCoolingStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_horizontal_tilt_angle.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Horizontal Tilt Angle characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentHorizontalTiltAngleCharacteristic(Characteristic); impl CurrentHorizontalTiltAngleCharacteristic { /// Creates a new Current Horizontal Tilt Angle characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentHorizontalTiltAngle, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::ArcDegrees), max_value: Some(90), min_value: Some(-90), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentHorizontalTiltAngleCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentHorizontalTiltAngleCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentHorizontalTiltAngleCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentHorizontalTiltAngleCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_humidifier_dehumidifier_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Humidifier-Dehumidifier State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentHumidifierDehumidifierStateCharacteristic(Characteristic); pub enum Value { Inactive = 0, Idle = 1, Humidifying = 2, Dehumidifying = 3, } impl CurrentHumidifierDehumidifierStateCharacteristic { /// Creates a new Current Humidifier-Dehumidifier State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentHumidifierDehumidifierState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // INACTIVE 1, // IDLE 2, // HUMIDIFYING 3, // DEHUMIDIFYING ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentHumidifierDehumidifierStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentHumidifierDehumidifierStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentHumidifierDehumidifierStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentHumidifierDehumidifierStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_light_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Light Level characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentLightLevelCharacteristic(Characteristic); impl CurrentLightLevelCharacteristic { /// Creates a new Current Light Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentLightLevel, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::Lux), max_value: Some(100000 as f32), min_value: Some(0.0001 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentLightLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentLightLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentLightLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentLightLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_media_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Media State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentMediaStateCharacteristic(Characteristic); impl CurrentMediaStateCharacteristic { /// Creates a new Current Media State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentMediaState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(5), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentMediaStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentMediaStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentMediaStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentMediaStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_position.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Position characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentPositionCharacteristic(Characteristic); impl CurrentPositionCharacteristic { /// Creates a new Current Position characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentPosition, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::Percentage), max_value: Some(100), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentPositionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentPositionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentPositionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentPositionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_relative_humidity.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Relative Humidity characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentRelativeHumidityCharacteristic(Characteristic); impl CurrentRelativeHumidityCharacteristic { /// Creates a new Current Relative Humidity characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentRelativeHumidity, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::Percentage), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentRelativeHumidityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentRelativeHumidityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentRelativeHumidityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentRelativeHumidityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_slat_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Slat State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentSlatStateCharacteristic(Characteristic); pub enum Value { Inactive = 0, Fixed = 1, Swinging = 2, Jammed = 3, } impl CurrentSlatStateCharacteristic { /// Creates a new Current Slat State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentSlatState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // INACTIVE 1, // FIXED 2, // SWINGING 3, // JAMMED ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentSlatStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentSlatStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentSlatStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentSlatStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_temperature.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Temperature characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentTemperatureCharacteristic(Characteristic); impl CurrentTemperatureCharacteristic { /// Creates a new Current Temperature characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentTemperature, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::Celsius), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(0.1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentTemperatureCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentTemperatureCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentTemperatureCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentTemperatureCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_tilt_angle.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Tilt Angle characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentTiltAngleCharacteristic(Characteristic); impl CurrentTiltAngleCharacteristic { /// Creates a new Current Tilt Angle characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentTiltAngle, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::ArcDegrees), max_value: Some(90), min_value: Some(-90), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentTiltAngleCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentTiltAngleCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentTiltAngleCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentTiltAngleCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_transport.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Transport characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentTransportCharacteristic(Characteristic); impl CurrentTransportCharacteristic { /// Creates a new Current Transport characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentTransport, format: Format::Bool, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentTransportCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentTransportCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentTransportCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentTransportCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_vertical_tilt_angle.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Vertical Tilt Angle characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentVerticalTiltAngleCharacteristic(Characteristic); impl CurrentVerticalTiltAngleCharacteristic { /// Creates a new Current Vertical Tilt Angle characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentVerticalTiltAngle, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::ArcDegrees), max_value: Some(90), min_value: Some(-90), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentVerticalTiltAngleCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentVerticalTiltAngleCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentVerticalTiltAngleCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentVerticalTiltAngleCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_visibility_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Visibility State characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentVisibilityStateCharacteristic(Characteristic); impl CurrentVisibilityStateCharacteristic { /// Creates a new Current Visibility State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentVisibilityState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentVisibilityStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentVisibilityStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentVisibilityStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentVisibilityStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/current_water_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Current Water Level characteristic. #[derive(Debug, Default, Serialize)] pub struct CurrentWaterLevelCharacteristic(Characteristic); impl CurrentWaterLevelCharacteristic { /// Creates a new Current Water Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::CurrentWaterLevel, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::Percentage), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for CurrentWaterLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for CurrentWaterLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for CurrentWaterLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for CurrentWaterLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/data_stream_hap_transport.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Data Stream HAP Transport characteristic. #[derive(Debug, Default, Serialize)] pub struct DataStreamHapTransportCharacteristic(Characteristic>); impl DataStreamHapTransportCharacteristic { /// Creates a new Data Stream HAP Transport characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::DataStreamHapTransport, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for DataStreamHapTransportCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for DataStreamHapTransportCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for DataStreamHapTransportCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for DataStreamHapTransportCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/data_stream_hap_transport_interrupt.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Data Stream HAP Transport Interrupt characteristic. #[derive(Debug, Default, Serialize)] pub struct DataStreamHapTransportInterruptCharacteristic(Characteristic>); impl DataStreamHapTransportInterruptCharacteristic { /// Creates a new Data Stream HAP Transport Interrupt characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::DataStreamHapTransportInterrupt, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for DataStreamHapTransportInterruptCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for DataStreamHapTransportInterruptCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for DataStreamHapTransportInterruptCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for DataStreamHapTransportInterruptCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/digital_zoom.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Digital Zoom characteristic. #[derive(Debug, Default, Serialize)] pub struct DigitalZoomCharacteristic(Characteristic); impl DigitalZoomCharacteristic { /// Creates a new Digital Zoom characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::DigitalZoom, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], step_value: Some(0.1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for DigitalZoomCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for DigitalZoomCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for DigitalZoomCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for DigitalZoomCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/display_order.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Display Order characteristic. #[derive(Debug, Default, Serialize)] pub struct DisplayOrderCharacteristic(Characteristic>); impl DisplayOrderCharacteristic { /// Creates a new Display Order characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::DisplayOrder, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for DisplayOrderCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for DisplayOrderCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for DisplayOrderCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for DisplayOrderCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/event_retransmission_maximum.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Event Retransmission Maximum characteristic. #[derive(Debug, Default, Serialize)] pub struct EventRetransmissionMaximumCharacteristic(Characteristic); impl EventRetransmissionMaximumCharacteristic { /// Creates a new Event Retransmission Maximum characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::EventRetransmissionMaximum, format: Format::UInt8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for EventRetransmissionMaximumCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for EventRetransmissionMaximumCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for EventRetransmissionMaximumCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for EventRetransmissionMaximumCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/event_snapshots_active.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Event Snapshots Active characteristic. #[derive(Debug, Default, Serialize)] pub struct EventSnapshotsActiveCharacteristic(Characteristic); impl EventSnapshotsActiveCharacteristic { /// Creates a new Event Snapshots Active characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::EventSnapshotsActive, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for EventSnapshotsActiveCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for EventSnapshotsActiveCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for EventSnapshotsActiveCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for EventSnapshotsActiveCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/event_transmission_counters.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Event Transmission Counters characteristic. #[derive(Debug, Default, Serialize)] pub struct EventTransmissionCountersCharacteristic(Characteristic); impl EventTransmissionCountersCharacteristic { /// Creates a new Event Transmission Counters characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::EventTransmissionCounters, format: Format::UInt32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for EventTransmissionCountersCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for EventTransmissionCountersCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for EventTransmissionCountersCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for EventTransmissionCountersCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/filter_change_indication.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Filter Change indication characteristic. #[derive(Debug, Default, Serialize)] pub struct FilterChangeIndicationCharacteristic(Characteristic); pub enum Value { NoChange = 0, Change = 1, } impl FilterChangeIndicationCharacteristic { /// Creates a new Filter Change indication characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::FilterChangeIndication, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // NO_CHANGE 1, // CHANGE ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for FilterChangeIndicationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for FilterChangeIndicationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for FilterChangeIndicationCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for FilterChangeIndicationCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/filter_life_level.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Filter Life Level characteristic. #[derive(Debug, Default, Serialize)] pub struct FilterLifeLevelCharacteristic(Characteristic); impl FilterLifeLevelCharacteristic { /// Creates a new Filter Life Level characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::FilterLifeLevel, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for FilterLifeLevelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for FilterLifeLevelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for FilterLifeLevelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for FilterLifeLevelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/filter_reset_change_indication.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Filter Reset Change Indication characteristic. #[derive(Debug, Default, Serialize)] pub struct FilterResetChangeIndicationCharacteristic(Characteristic); impl FilterResetChangeIndicationCharacteristic { /// Creates a new Filter Reset Change Indication characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::FilterResetChangeIndication, format: Format::UInt8, perms: vec![ Perm::PairedWrite, ], max_value: Some(1), min_value: Some(1), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for FilterResetChangeIndicationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for FilterResetChangeIndicationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for FilterResetChangeIndicationCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for FilterResetChangeIndicationCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/firmware_revision.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Firmware Revision characteristic. #[derive(Debug, Default, Serialize)] pub struct FirmwareRevisionCharacteristic(Characteristic); impl FirmwareRevisionCharacteristic { /// Creates a new Firmware Revision characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::FirmwareRevision, format: Format::String, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for FirmwareRevisionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for FirmwareRevisionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for FirmwareRevisionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for FirmwareRevisionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/firmware_update_readiness.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Firmware Update Readiness characteristic. #[derive(Debug, Default, Serialize)] pub struct FirmwareUpdateReadinessCharacteristic(Characteristic>); impl FirmwareUpdateReadinessCharacteristic { /// Creates a new Firmware Update Readiness characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::FirmwareUpdateReadiness, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for FirmwareUpdateReadinessCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for FirmwareUpdateReadinessCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for FirmwareUpdateReadinessCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for FirmwareUpdateReadinessCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/firmware_update_status.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Firmware Update Status characteristic. #[derive(Debug, Default, Serialize)] pub struct FirmwareUpdateStatusCharacteristic(Characteristic>); impl FirmwareUpdateStatusCharacteristic { /// Creates a new Firmware Update Status characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::FirmwareUpdateStatus, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for FirmwareUpdateStatusCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for FirmwareUpdateStatusCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for FirmwareUpdateStatusCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for FirmwareUpdateStatusCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/hardware_finish.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Hardware Finish characteristic. #[derive(Debug, Default, Serialize)] pub struct HardwareFinishCharacteristic(Characteristic>); impl HardwareFinishCharacteristic { /// Creates a new Hardware Finish characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::HardwareFinish, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for HardwareFinishCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for HardwareFinishCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for HardwareFinishCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for HardwareFinishCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/hardware_revision.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Hardware Revision characteristic. #[derive(Debug, Default, Serialize)] pub struct HardwareRevisionCharacteristic(Characteristic); impl HardwareRevisionCharacteristic { /// Creates a new Hardware Revision characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::HardwareRevision, format: Format::String, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for HardwareRevisionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for HardwareRevisionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for HardwareRevisionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for HardwareRevisionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/heart_beat.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Heart Beat characteristic. #[derive(Debug, Default, Serialize)] pub struct HeartBeatCharacteristic(Characteristic); impl HeartBeatCharacteristic { /// Creates a new Heart Beat characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::HeartBeat, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for HeartBeatCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for HeartBeatCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for HeartBeatCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for HeartBeatCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/heating_threshold_temperature.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Heating Threshold Temperature characteristic. #[derive(Debug, Default, Serialize)] pub struct HeatingThresholdTemperatureCharacteristic(Characteristic); impl HeatingThresholdTemperatureCharacteristic { /// Creates a new Heating Threshold Temperature characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::HeatingThresholdTemperature, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Celsius), max_value: Some(25 as f32), min_value: Some(0 as f32), step_value: Some(0.1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for HeatingThresholdTemperatureCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for HeatingThresholdTemperatureCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for HeatingThresholdTemperatureCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for HeatingThresholdTemperatureCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/hold_position.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Hold Position characteristic. #[derive(Debug, Default, Serialize)] pub struct HoldPositionCharacteristic(Characteristic); impl HoldPositionCharacteristic { /// Creates a new Hold Position characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::HoldPosition, format: Format::Bool, perms: vec![ Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for HoldPositionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for HoldPositionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for HoldPositionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for HoldPositionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/homekit_camera_active.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// HomeKit Camera Active characteristic. #[derive(Debug, Default, Serialize)] pub struct HomekitCameraActiveCharacteristic(Characteristic); impl HomekitCameraActiveCharacteristic { /// Creates a new HomeKit Camera Active characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::HomekitCameraActive, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for HomekitCameraActiveCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for HomekitCameraActiveCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for HomekitCameraActiveCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for HomekitCameraActiveCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/hue.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Hue characteristic. #[derive(Debug, Default, Serialize)] pub struct HueCharacteristic(Characteristic); impl HueCharacteristic { /// Creates a new Hue characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Hue, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::ArcDegrees), max_value: Some(360 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for HueCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for HueCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for HueCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for HueCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/identifier.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Identifier characteristic. #[derive(Debug, Default, Serialize)] pub struct IdentifierCharacteristic(Characteristic); impl IdentifierCharacteristic { /// Creates a new Identifier characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Identifier, format: Format::UInt32, perms: vec![ Perm::PairedRead, ], min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for IdentifierCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for IdentifierCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for IdentifierCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for IdentifierCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/identify.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Identify characteristic. #[derive(Debug, Default, Serialize)] pub struct IdentifyCharacteristic(Characteristic); impl IdentifyCharacteristic { /// Creates a new Identify characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Identify, format: Format::Bool, perms: vec![ Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for IdentifyCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for IdentifyCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for IdentifyCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for IdentifyCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/image_mirroring.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Image Mirroring characteristic. #[derive(Debug, Default, Serialize)] pub struct ImageMirroringCharacteristic(Characteristic); impl ImageMirroringCharacteristic { /// Creates a new Image Mirroring characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ImageMirroring, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ImageMirroringCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ImageMirroringCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ImageMirroringCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ImageMirroringCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/image_rotation.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Image Rotation characteristic. #[derive(Debug, Default, Serialize)] pub struct ImageRotationCharacteristic(Characteristic); impl ImageRotationCharacteristic { /// Creates a new Image Rotation characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ImageRotation, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::ArcDegrees), max_value: Some(360), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ImageRotationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ImageRotationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ImageRotationCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ImageRotationCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/in_use.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// In Use characteristic. #[derive(Debug, Default, Serialize)] pub struct InUseCharacteristic(Characteristic); impl InUseCharacteristic { /// Creates a new In Use characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::InUse, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for InUseCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for InUseCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for InUseCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for InUseCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/input_device_type.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Input Device Type characteristic. #[derive(Debug, Default, Serialize)] pub struct InputDeviceTypeCharacteristic(Characteristic); impl InputDeviceTypeCharacteristic { /// Creates a new Input Device Type characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::InputDeviceType, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(6), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for InputDeviceTypeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for InputDeviceTypeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for InputDeviceTypeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for InputDeviceTypeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/input_source_type.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Input Source Type characteristic. #[derive(Debug, Default, Serialize)] pub struct InputSourceTypeCharacteristic(Characteristic); impl InputSourceTypeCharacteristic { /// Creates a new Input Source Type characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::InputSourceType, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(10), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for InputSourceTypeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for InputSourceTypeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for InputSourceTypeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for InputSourceTypeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/is_configured.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Is Configured characteristic. #[derive(Debug, Default, Serialize)] pub struct IsConfiguredCharacteristic(Characteristic); impl IsConfiguredCharacteristic { /// Creates a new Is Configured characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::IsConfigured, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for IsConfiguredCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for IsConfiguredCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for IsConfiguredCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for IsConfiguredCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/label_index.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Label Index characteristic. #[derive(Debug, Default, Serialize)] pub struct LabelIndexCharacteristic(Characteristic); impl LabelIndexCharacteristic { /// Creates a new Label Index characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::LabelIndex, format: Format::UInt8, perms: vec![ Perm::PairedRead, ], max_value: Some(255), min_value: Some(1), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LabelIndexCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LabelIndexCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for LabelIndexCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for LabelIndexCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/label_namespace.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Label Namespace characteristic. #[derive(Debug, Default, Serialize)] pub struct LabelNamespaceCharacteristic(Characteristic); impl LabelNamespaceCharacteristic { /// Creates a new Label Namespace characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::LabelNamespace, format: Format::UInt8, perms: vec![ Perm::PairedRead, ], max_value: Some(4), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LabelNamespaceCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LabelNamespaceCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for LabelNamespaceCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for LabelNamespaceCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/leak_detected.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Leak Detected characteristic. #[derive(Debug, Default, Serialize)] pub struct LeakDetectedCharacteristic(Characteristic); pub enum Value { LeakNotDetected = 0, LeakDetected = 1, } impl LeakDetectedCharacteristic { /// Creates a new Leak Detected characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::LeakDetected, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // LEAK_NOT_DETECTED 1, // LEAK_DETECTED ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LeakDetectedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LeakDetectedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for LeakDetectedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for LeakDetectedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/list_pairings.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// List Pairings characteristic. #[derive(Debug, Default, Serialize)] pub struct ListPairingsCharacteristic(Characteristic>); impl ListPairingsCharacteristic { /// Creates a new List Pairings characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::ListPairings, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ListPairingsCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ListPairingsCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for ListPairingsCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for ListPairingsCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/lock_control_point.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Lock Control Point characteristic. #[derive(Debug, Default, Serialize)] pub struct LockControlPointCharacteristic(Characteristic>); impl LockControlPointCharacteristic { /// Creates a new Lock Control Point characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::LockControlPoint, format: Format::Tlv8, perms: vec![ Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LockControlPointCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LockControlPointCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for LockControlPointCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for LockControlPointCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/lock_current_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Lock Current State characteristic. #[derive(Debug, Default, Serialize)] pub struct LockCurrentStateCharacteristic(Characteristic); pub enum Value { Num0 = 0, Num1 = 1, } impl LockCurrentStateCharacteristic { /// Creates a new Lock Current State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::LockCurrentState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // 0 1, // 1 ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LockCurrentStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LockCurrentStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for LockCurrentStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for LockCurrentStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/lock_last_known_action.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Lock Last Known Action characteristic. #[derive(Debug, Default, Serialize)] pub struct LockLastKnownActionCharacteristic(Characteristic); impl LockLastKnownActionCharacteristic { /// Creates a new Lock Last Known Action characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::LockLastKnownAction, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(8), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LockLastKnownActionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LockLastKnownActionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for LockLastKnownActionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for LockLastKnownActionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/lock_management_auto_security_timeout.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Lock Management Auto Security Timeout characteristic. #[derive(Debug, Default, Serialize)] pub struct LockManagementAutoSecurityTimeoutCharacteristic(Characteristic); impl LockManagementAutoSecurityTimeoutCharacteristic { /// Creates a new Lock Management Auto Security Timeout characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::LockManagementAutoSecurityTimeout, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Seconds), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LockManagementAutoSecurityTimeoutCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LockManagementAutoSecurityTimeoutCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for LockManagementAutoSecurityTimeoutCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for LockManagementAutoSecurityTimeoutCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/lock_physical_controls.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Lock Physical Controls characteristic. #[derive(Debug, Default, Serialize)] pub struct LockPhysicalControlsCharacteristic(Characteristic); impl LockPhysicalControlsCharacteristic { /// Creates a new Lock Physical Controls characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::LockPhysicalControls, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LockPhysicalControlsCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LockPhysicalControlsCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for LockPhysicalControlsCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for LockPhysicalControlsCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/lock_target_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Lock Target State characteristic. #[derive(Debug, Default, Serialize)] pub struct LockTargetStateCharacteristic(Characteristic); pub enum Value { Num0 = 0, Num1 = 1, } impl LockTargetStateCharacteristic { /// Creates a new Lock Target State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::LockTargetState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // 0 1, // 1 ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LockTargetStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LockTargetStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for LockTargetStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for LockTargetStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/logs.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Logs characteristic. #[derive(Debug, Default, Serialize)] pub struct LogsCharacteristic(Characteristic>); impl LogsCharacteristic { /// Creates a new Logs characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::Logs, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for LogsCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for LogsCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for LogsCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for LogsCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/mac_retransmission_maximum.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// MAC Retransmission Maximum characteristic. #[derive(Debug, Default, Serialize)] pub struct MacRetransmissionMaximumCharacteristic(Characteristic); impl MacRetransmissionMaximumCharacteristic { /// Creates a new MAC Retransmission Maximum characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::MacRetransmissionMaximum, format: Format::UInt8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for MacRetransmissionMaximumCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for MacRetransmissionMaximumCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for MacRetransmissionMaximumCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for MacRetransmissionMaximumCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/mac_transmission_counters.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// MAC Transmission Counters characteristic. #[derive(Debug, Default, Serialize)] pub struct MacTransmissionCountersCharacteristic(Characteristic>); impl MacTransmissionCountersCharacteristic { /// Creates a new MAC Transmission Counters characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::MacTransmissionCounters, format: Format::Data, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for MacTransmissionCountersCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for MacTransmissionCountersCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for MacTransmissionCountersCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for MacTransmissionCountersCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/managed_network_enable.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Managed Network Enable characteristic. #[derive(Debug, Default, Serialize)] pub struct ManagedNetworkEnableCharacteristic(Characteristic); impl ManagedNetworkEnableCharacteristic { /// Creates a new Managed Network Enable characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ManagedNetworkEnable, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ManagedNetworkEnableCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ManagedNetworkEnableCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ManagedNetworkEnableCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ManagedNetworkEnableCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/manually_disabled.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Manually disabled characteristic. #[derive(Debug, Default, Serialize)] pub struct ManuallyDisabledCharacteristic(Characteristic); impl ManuallyDisabledCharacteristic { /// Creates a new Manually disabled characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ManuallyDisabled, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ManuallyDisabledCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ManuallyDisabledCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ManuallyDisabledCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ManuallyDisabledCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/manufacturer.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Manufacturer characteristic. #[derive(Debug, Default, Serialize)] pub struct ManufacturerCharacteristic(Characteristic); impl ManufacturerCharacteristic { /// Creates a new Manufacturer characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Manufacturer, format: Format::String, perms: vec![ Perm::PairedRead, ], max_len: Some(64), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ManufacturerCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ManufacturerCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ManufacturerCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ManufacturerCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/maximum_transmit_power.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Maximum Transmit Power characteristic. #[derive(Debug, Default, Serialize)] pub struct MaximumTransmitPowerCharacteristic(Characteristic); impl MaximumTransmitPowerCharacteristic { /// Creates a new Maximum Transmit Power characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::MaximumTransmitPower, format: Format::Int32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for MaximumTransmitPowerCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for MaximumTransmitPowerCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for MaximumTransmitPowerCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for MaximumTransmitPowerCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/mod.rs ================================================ // this file is auto-generated by hap-codegen /// Access Code Control Point characteristic definition. pub mod access_code_control_point; /// Access Code Supported Configuration characteristic definition. pub mod access_code_supported_configuration; /// Access Control Level characteristic definition. pub mod access_control_level; /// Accessory Flags characteristic definition. pub mod accessory_flags; /// Accessory Identifier characteristic definition. pub mod accessory_identifier; /// Active characteristic definition. pub mod active; /// Active Identifier characteristic definition. pub mod active_identifier; /// Activity Interval characteristic definition. pub mod activity_interval; /// Administrator Only Access characteristic definition. pub mod administrator_only_access; /// Air Particulate Density characteristic definition. pub mod air_particulate_density; /// Air Particulate Size characteristic definition. pub mod air_particulate_size; /// AirPlay Enable characteristic definition. pub mod airplay_enable; /// Application Matching Identifier characteristic definition. pub mod application_matching_identifier; /// Asset Update Readiness characteristic definition. pub mod asset_update_readiness; /// Audio Feedback characteristic definition. pub mod audio_feedback; /// Battery Level characteristic definition. pub mod battery_level; /// Brightness characteristic definition. pub mod brightness; /// Button Event characteristic definition. pub mod button_event; /// Camera Operating Mode Indicator characteristic definition. pub mod camera_operating_mode_indicator; /// Carbon dioxide Detected characteristic definition. pub mod carbon_dioxide_detected; /// Carbon dioxide Level characteristic definition. pub mod carbon_dioxide_level; /// Carbon dioxide Peak Level characteristic definition. pub mod carbon_dioxide_peak_level; /// Carbon monoxide Detected characteristic definition. pub mod carbon_monoxide_detected; /// Carbon monoxide Level characteristic definition. pub mod carbon_monoxide_level; /// Carbon monoxide Peak Level characteristic definition. pub mod carbon_monoxide_peak_level; /// CCA Energy Detect Threshold characteristic definition. pub mod cca_energy_detect_threshold; /// CCA Signal Detect Threshold characteristic definition. pub mod cca_signal_detect_threshold; /// Characteristic Value Active Transition Count characteristic definition. pub mod characteristic_value_active_transition_count; /// Characteristic Value Transition Control characteristic definition. pub mod characteristic_value_transition_control; /// Charging State characteristic definition. pub mod charging_state; /// Closed Captions characteristic definition. pub mod closed_captions; /// Cloud Relay Control Point characteristic definition. pub mod cloud_relay_control_point; /// Cloud Relay Current State characteristic definition. pub mod cloud_relay_current_state; /// Cloud Relay Enable Status characteristic definition. pub mod cloud_relay_enable_status; /// Color Temperature characteristic definition. pub mod color_temperature; /// Configuration State characteristic definition. pub mod configuration_state; /// Configured Name characteristic definition. pub mod configured_name; /// Contact Sensor State characteristic definition. pub mod contact_sensor_state; /// Cooling Threshold Temperature characteristic definition. pub mod cooling_threshold_temperature; /// Current Air Purifier State characteristic definition. pub mod current_air_purifier_state; /// Current Air Quality characteristic definition. pub mod current_air_quality; /// Current Door State characteristic definition. pub mod current_door_state; /// Current Fan State characteristic definition. pub mod current_fan_state; /// Current Heater-Cooler State characteristic definition. pub mod current_heater_cooler_state; /// Current Heating Cooling State characteristic definition. pub mod current_heating_cooling_state; /// Current Horizontal Tilt Angle characteristic definition. pub mod current_horizontal_tilt_angle; /// Current Humidifier-Dehumidifier State characteristic definition. pub mod current_humidifier_dehumidifier_state; /// Current Light Level characteristic definition. pub mod current_light_level; /// Current Media State characteristic definition. pub mod current_media_state; /// Current Position characteristic definition. pub mod current_position; /// Current Relative Humidity characteristic definition. pub mod current_relative_humidity; /// Current Slat State characteristic definition. pub mod current_slat_state; /// Current Temperature characteristic definition. pub mod current_temperature; /// Current Tilt Angle characteristic definition. pub mod current_tilt_angle; /// Current Transport characteristic definition. pub mod current_transport; /// Current Vertical Tilt Angle characteristic definition. pub mod current_vertical_tilt_angle; /// Current Visibility State characteristic definition. pub mod current_visibility_state; /// Current Water Level characteristic definition. pub mod current_water_level; /// Data Stream HAP Transport characteristic definition. pub mod data_stream_hap_transport; /// Data Stream HAP Transport Interrupt characteristic definition. pub mod data_stream_hap_transport_interrupt; /// Digital Zoom characteristic definition. pub mod digital_zoom; /// Display Order characteristic definition. pub mod display_order; /// Event Retransmission Maximum characteristic definition. pub mod event_retransmission_maximum; /// Event Snapshots Active characteristic definition. pub mod event_snapshots_active; /// Event Transmission Counters characteristic definition. pub mod event_transmission_counters; /// Filter Change indication characteristic definition. pub mod filter_change_indication; /// Filter Life Level characteristic definition. pub mod filter_life_level; /// Filter Reset Change Indication characteristic definition. pub mod filter_reset_change_indication; /// Firmware Revision characteristic definition. pub mod firmware_revision; /// Firmware Update Readiness characteristic definition. pub mod firmware_update_readiness; /// Firmware Update Status characteristic definition. pub mod firmware_update_status; /// Hardware Finish characteristic definition. pub mod hardware_finish; /// Hardware Revision characteristic definition. pub mod hardware_revision; /// Heart Beat characteristic definition. pub mod heart_beat; /// Heating Threshold Temperature characteristic definition. pub mod heating_threshold_temperature; /// Hold Position characteristic definition. pub mod hold_position; /// HomeKit Camera Active characteristic definition. pub mod homekit_camera_active; /// Hue characteristic definition. pub mod hue; /// Identifier characteristic definition. pub mod identifier; /// Identify characteristic definition. pub mod identify; /// Image Mirroring characteristic definition. pub mod image_mirroring; /// Image Rotation characteristic definition. pub mod image_rotation; /// In Use characteristic definition. pub mod in_use; /// Input Device Type characteristic definition. pub mod input_device_type; /// Input Source Type characteristic definition. pub mod input_source_type; /// Is Configured characteristic definition. pub mod is_configured; /// Label Index characteristic definition. pub mod label_index; /// Label Namespace characteristic definition. pub mod label_namespace; /// Leak Detected characteristic definition. pub mod leak_detected; /// List Pairings characteristic definition. pub mod list_pairings; /// Lock Control Point characteristic definition. pub mod lock_control_point; /// Lock Current State characteristic definition. pub mod lock_current_state; /// Lock Last Known Action characteristic definition. pub mod lock_last_known_action; /// Lock Management Auto Security Timeout characteristic definition. pub mod lock_management_auto_security_timeout; /// Lock Physical Controls characteristic definition. pub mod lock_physical_controls; /// Lock Target State characteristic definition. pub mod lock_target_state; /// Logs characteristic definition. pub mod logs; /// MAC Retransmission Maximum characteristic definition. pub mod mac_retransmission_maximum; /// MAC Transmission Counters characteristic definition. pub mod mac_transmission_counters; /// Managed Network Enable characteristic definition. pub mod managed_network_enable; /// Manually disabled characteristic definition. pub mod manually_disabled; /// Manufacturer characteristic definition. pub mod manufacturer; /// Maximum Transmit Power characteristic definition. pub mod maximum_transmit_power; /// Model characteristic definition. pub mod model; /// Motion Detected characteristic definition. pub mod motion_detected; /// Multifunction Button characteristic definition. pub mod multifunction_button; /// Mute characteristic definition. pub mod mute; /// Name characteristic definition. pub mod name; /// Network Access Violation Control characteristic definition. pub mod network_access_violation_control; /// Network Client Control characteristic definition. pub mod network_client_control; /// Network Client Status Control characteristic definition. pub mod network_client_status_control; /// NFC Access Control Point characteristic definition. pub mod nfc_access_control_point; /// NFC Access Supported Configuration characteristic definition. pub mod nfc_access_supported_configuration; /// Night Vision characteristic definition. pub mod night_vision; /// Nitrogen dioxide Density characteristic definition. pub mod nitrogen_dioxide_density; /// Obstruction Detected characteristic definition. pub mod obstruction_detected; /// Occupancy Detected characteristic definition. pub mod occupancy_detected; /// Operating State Response characteristic definition. pub mod operating_state_response; /// Optical Zoom characteristic definition. pub mod optical_zoom; /// Outlet In Use characteristic definition. pub mod outlet_in_use; /// Ozone Density characteristic definition. pub mod ozone_density; /// Pair Setup characteristic definition. pub mod pair_setup; /// Pair Verify characteristic definition. pub mod pair_verify; /// Pairing Features characteristic definition. pub mod pairing_features; /// Password Setting characteristic definition. pub mod password_setting; /// Periodic Snapshots Active characteristic definition. pub mod periodic_snapshots_active; /// Picture Mode characteristic definition. pub mod picture_mode; /// Ping characteristic definition. pub mod ping; /// PM10 Density characteristic definition. pub mod pm10_density; /// PM2.5 Density characteristic definition. pub mod pm2_5_density; /// Position State characteristic definition. pub mod position_state; /// Power Mode Selection characteristic definition. pub mod power_mode_selection; /// Power State characteristic definition. pub mod power_state; /// Product Data characteristic definition. pub mod product_data; /// Program Mode characteristic definition. pub mod program_mode; /// Programmable Switch Event characteristic definition. pub mod programmable_switch_event; /// Programmable Switch Output State characteristic definition. pub mod programmable_switch_output_state; /// Received Signal Strength Indication characteristic definition. pub mod received_signal_strength_indication; /// Receiver Sensitivity characteristic definition. pub mod receiver_sensitivity; /// recording audio active characteristic definition. pub mod recording_audio_active; /// Relative Humidity Dehumidifier Threshold characteristic definition. pub mod relative_humidity_dehumidifier_threshold; /// Relative Humidity Humidifier Threshold characteristic definition. pub mod relative_humidity_humidifier_threshold; /// Remaining Duration characteristic definition. pub mod remaining_duration; /// Remote Key characteristic definition. pub mod remote_key; /// Rotation Direction characteristic definition. pub mod rotation_direction; /// Rotation Speed characteristic definition. pub mod rotation_speed; /// Router Status characteristic definition. pub mod router_status; /// Saturation characteristic definition. pub mod saturation; /// Security System Alarm Type characteristic definition. pub mod security_system_alarm_type; /// Security System Current State characteristic definition. pub mod security_system_current_state; /// Security System Target State characteristic definition. pub mod security_system_target_state; /// Selected Audio Stream Configuration characteristic definition. pub mod selected_audio_stream_configuration; /// Selected Camera Recording Configuration characteristic definition. pub mod selected_camera_recording_configuration; /// Selected Diagnostics Modes characteristic definition. pub mod selected_diagnostics_modes; /// Selected Stream Configuration characteristic definition. pub mod selected_stream_configuration; /// Serial Number characteristic definition. pub mod serial_number; /// Service Signature characteristic definition. pub mod service_signature; /// Set Duration characteristic definition. pub mod set_duration; /// Setup Data Stream Transport characteristic definition. pub mod setup_data_stream_transport; /// Setup Endpoint characteristic definition. pub mod setup_endpoint; /// Setup Transfer Transport characteristic definition. pub mod setup_transfer_transport; /// Signal-to-noise Ratio characteristic definition. pub mod signal_to_noise_ratio; /// Siri Enable characteristic definition. pub mod siri_enable; /// Siri Endpoint Session Status characteristic definition. pub mod siri_endpoint_session_status; /// Siri Engine Version characteristic definition. pub mod siri_engine_version; /// Siri Input Type characteristic definition. pub mod siri_input_type; /// Siri Light On Use characteristic definition. pub mod siri_light_on_use; /// Siri Listening characteristic definition. pub mod siri_listening; /// Siri Touch To Use characteristic definition. pub mod siri_touch_to_use; /// Slat Type characteristic definition. pub mod slat_type; /// Sleep Discovery Mode characteristic definition. pub mod sleep_discovery_mode; /// Sleep Interval characteristic definition. pub mod sleep_interval; /// Smoke Detected characteristic definition. pub mod smoke_detected; /// Software Revision characteristic definition. pub mod software_revision; /// Staged Firmware Version characteristic definition. pub mod staged_firmware_version; /// Status Active characteristic definition. pub mod status_active; /// Status Fault characteristic definition. pub mod status_fault; /// Status Jammed characteristic definition. pub mod status_jammed; /// Status Low Battery characteristic definition. pub mod status_low_battery; /// Status Tampered characteristic definition. pub mod status_tampered; /// Streaming Status characteristic definition. pub mod streaming_status; /// Sulphur dioxide Density characteristic definition. pub mod sulphur_dioxide_density; /// Supported Asset Types characteristic definition. pub mod supported_asset_types; /// Supported Audio Recording Configuration characteristic definition. pub mod supported_audio_recording_configuration; /// Supported Audio Stream Configuration characteristic definition. pub mod supported_audio_stream_configuration; /// Supported Camera Recording Configuration characteristic definition. pub mod supported_camera_recording_configuration; /// Supported Characteristic Value Transition Configuration characteristic definition. pub mod supported_characteristic_value_transition_configuration; /// Supported Data Stream Transport Configuration characteristic definition. pub mod supported_data_stream_transport_configuration; /// Supported Diagnostics Modes characteristic definition. pub mod supported_diagnostics_modes; /// Supported Diagnostics Snapshot characteristic definition. pub mod supported_diagnostics_snapshot; /// Supported Firmware Update Configuration characteristic definition. pub mod supported_firmware_update_configuration; /// Supported Router Configuration characteristic definition. pub mod supported_router_configuration; /// Supported RTP Configuration characteristic definition. pub mod supported_rtp_configuration; /// Supported Target Configuration characteristic definition. pub mod supported_target_configuration; /// Supported Transfer Transport Configuration characteristic definition. pub mod supported_transfer_transport_configuration; /// Supported Video Recording Configuration characteristic definition. pub mod supported_video_recording_configuration; /// Supported Video Stream Configuration characteristic definition. pub mod supported_video_stream_configuration; /// Swing Mode characteristic definition. pub mod swing_mode; /// Target Air Purifier State characteristic definition. pub mod target_air_purifier_state; /// Target Door State characteristic definition. pub mod target_door_state; /// Target Fan State characteristic definition. pub mod target_fan_state; /// Target Heater-Cooler State characteristic definition. pub mod target_heater_cooler_state; /// Target Heating Cooling State characteristic definition. pub mod target_heating_cooling_state; /// Target Horizontal Tilt Angle characteristic definition. pub mod target_horizontal_tilt_angle; /// Target Humidifier-Dehumidifier State characteristic definition. pub mod target_humidifier_dehumidifier_state; /// Target List Configuration characteristic definition. pub mod target_list_configuration; /// Target Media State characteristic definition. pub mod target_media_state; /// Target Position characteristic definition. pub mod target_position; /// Target Relative Humidity characteristic definition. pub mod target_relative_humidity; /// Target Temperature characteristic definition. pub mod target_temperature; /// Target Tilt Angle characteristic definition. pub mod target_tilt_angle; /// Target Vertical Tilt Angle characteristic definition. pub mod target_vertical_tilt_angle; /// Target Visibility State characteristic definition. pub mod target_visibility_state; /// Temperature Display Units characteristic definition. pub mod temperature_display_units; /// Third Party Camera Active characteristic definition. pub mod third_party_camera_active; /// Thread Control Point characteristic definition. pub mod thread_control_point; /// Thread Node Capabilities characteristic definition. pub mod thread_node_capabilities; /// Thread OpenThread Version characteristic definition. pub mod thread_openthread_version; /// Thread Status characteristic definition. pub mod thread_status; /// Transmit Power characteristic definition. pub mod transmit_power; /// Valve Type characteristic definition. pub mod valve_type; /// Version characteristic definition. pub mod version; /// Video Analysis Active characteristic definition. pub mod video_analysis_active; /// Volatile Organic Compound Density characteristic definition. pub mod volatile_organic_compound_density; /// Volume characteristic definition. pub mod volume; /// Volume Control Type characteristic definition. pub mod volume_control_type; /// Volume Selector characteristic definition. pub mod volume_selector; /// Wake Configuration characteristic definition. pub mod wake_configuration; /// WAN Configuration List characteristic definition. pub mod wan_configuration_list; /// WAN Status List characteristic definition. pub mod wan_status_list; /// Wi-Fi Capabilities characteristic definition. pub mod wi_fi_capabilities; /// Wi-Fi Configuration Control characteristic definition. pub mod wi_fi_configuration_control; /// Wi-Fi Satellite Status characteristic definition. pub mod wi_fi_satellite_status; ================================================ FILE: src/characteristic/generated/model.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Model characteristic. #[derive(Debug, Default, Serialize)] pub struct ModelCharacteristic(Characteristic); impl ModelCharacteristic { /// Creates a new Model characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Model, format: Format::String, perms: vec![ Perm::PairedRead, ], max_len: Some(64), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ModelCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ModelCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ModelCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ModelCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/motion_detected.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Motion Detected characteristic. #[derive(Debug, Default, Serialize)] pub struct MotionDetectedCharacteristic(Characteristic); impl MotionDetectedCharacteristic { /// Creates a new Motion Detected characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::MotionDetected, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for MotionDetectedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for MotionDetectedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for MotionDetectedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for MotionDetectedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/multifunction_button.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Multifunction Button characteristic. #[derive(Debug, Default, Serialize)] pub struct MultifunctionButtonCharacteristic(Characteristic); impl MultifunctionButtonCharacteristic { /// Creates a new Multifunction Button characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::MultifunctionButton, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for MultifunctionButtonCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for MultifunctionButtonCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for MultifunctionButtonCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for MultifunctionButtonCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/mute.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Mute characteristic. #[derive(Debug, Default, Serialize)] pub struct MuteCharacteristic(Characteristic); impl MuteCharacteristic { /// Creates a new Mute characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Mute, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for MuteCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for MuteCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for MuteCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for MuteCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/name.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Name characteristic. #[derive(Debug, Default, Serialize)] pub struct NameCharacteristic(Characteristic); impl NameCharacteristic { /// Creates a new Name characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Name, format: Format::String, perms: vec![ Perm::PairedRead, ], max_len: Some(64), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for NameCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for NameCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for NameCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for NameCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/network_access_violation_control.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Network Access Violation Control characteristic. #[derive(Debug, Default, Serialize)] pub struct NetworkAccessViolationControlCharacteristic(Characteristic>); impl NetworkAccessViolationControlCharacteristic { /// Creates a new Network Access Violation Control characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::NetworkAccessViolationControl, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, Perm::WriteResponse, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for NetworkAccessViolationControlCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for NetworkAccessViolationControlCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for NetworkAccessViolationControlCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for NetworkAccessViolationControlCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/network_client_control.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Network Client Control characteristic. #[derive(Debug, Default, Serialize)] pub struct NetworkClientControlCharacteristic(Characteristic>); impl NetworkClientControlCharacteristic { /// Creates a new Network Client Control characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::NetworkClientControl, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, Perm::WriteResponse, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for NetworkClientControlCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for NetworkClientControlCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for NetworkClientControlCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for NetworkClientControlCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/network_client_status_control.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Network Client Status Control characteristic. #[derive(Debug, Default, Serialize)] pub struct NetworkClientStatusControlCharacteristic(Characteristic>); impl NetworkClientStatusControlCharacteristic { /// Creates a new Network Client Status Control characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::NetworkClientStatusControl, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, Perm::WriteResponse, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for NetworkClientStatusControlCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for NetworkClientStatusControlCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for NetworkClientStatusControlCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for NetworkClientStatusControlCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/nfc_access_control_point.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// NFC Access Control Point characteristic. #[derive(Debug, Default, Serialize)] pub struct NfcAccessControlPointCharacteristic(Characteristic>); impl NfcAccessControlPointCharacteristic { /// Creates a new NFC Access Control Point characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::NfcAccessControlPoint, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for NfcAccessControlPointCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for NfcAccessControlPointCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for NfcAccessControlPointCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for NfcAccessControlPointCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/nfc_access_supported_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// NFC Access Supported Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct NfcAccessSupportedConfigurationCharacteristic(Characteristic>); impl NfcAccessSupportedConfigurationCharacteristic { /// Creates a new NFC Access Supported Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::NfcAccessSupportedConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for NfcAccessSupportedConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for NfcAccessSupportedConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for NfcAccessSupportedConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for NfcAccessSupportedConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/night_vision.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Night Vision characteristic. #[derive(Debug, Default, Serialize)] pub struct NightVisionCharacteristic(Characteristic); impl NightVisionCharacteristic { /// Creates a new Night Vision characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::NightVision, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for NightVisionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for NightVisionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for NightVisionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for NightVisionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/nitrogen_dioxide_density.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Nitrogen dioxide Density characteristic. #[derive(Debug, Default, Serialize)] pub struct NitrogenDioxideDensityCharacteristic(Characteristic); impl NitrogenDioxideDensityCharacteristic { /// Creates a new Nitrogen dioxide Density characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::NitrogenDioxideDensity, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::MicrogramsPerCubicMeter), max_value: Some(1000 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for NitrogenDioxideDensityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for NitrogenDioxideDensityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for NitrogenDioxideDensityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for NitrogenDioxideDensityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/obstruction_detected.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Obstruction Detected characteristic. #[derive(Debug, Default, Serialize)] pub struct ObstructionDetectedCharacteristic(Characteristic); impl ObstructionDetectedCharacteristic { /// Creates a new Obstruction Detected characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ObstructionDetected, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ObstructionDetectedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ObstructionDetectedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ObstructionDetectedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ObstructionDetectedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/occupancy_detected.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Occupancy Detected characteristic. #[derive(Debug, Default, Serialize)] pub struct OccupancyDetectedCharacteristic(Characteristic); pub enum Value { OccupancyNotDetected = 0, OccupancyDetected = 1, } impl OccupancyDetectedCharacteristic { /// Creates a new Occupancy Detected characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::OccupancyDetected, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // OCCUPANCY_NOT_DETECTED 1, // OCCUPANCY_DETECTED ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for OccupancyDetectedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for OccupancyDetectedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for OccupancyDetectedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for OccupancyDetectedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/operating_state_response.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Operating State Response characteristic. #[derive(Debug, Default, Serialize)] pub struct OperatingStateResponseCharacteristic(Characteristic>); impl OperatingStateResponseCharacteristic { /// Creates a new Operating State Response characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::OperatingStateResponse, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for OperatingStateResponseCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for OperatingStateResponseCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for OperatingStateResponseCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for OperatingStateResponseCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/optical_zoom.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Optical Zoom characteristic. #[derive(Debug, Default, Serialize)] pub struct OpticalZoomCharacteristic(Characteristic); impl OpticalZoomCharacteristic { /// Creates a new Optical Zoom characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::OpticalZoom, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], step_value: Some(0.1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for OpticalZoomCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for OpticalZoomCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for OpticalZoomCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for OpticalZoomCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/outlet_in_use.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Outlet In Use characteristic. #[derive(Debug, Default, Serialize)] pub struct OutletInUseCharacteristic(Characteristic); impl OutletInUseCharacteristic { /// Creates a new Outlet In Use characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::OutletInUse, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for OutletInUseCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for OutletInUseCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for OutletInUseCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for OutletInUseCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/ozone_density.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Ozone Density characteristic. #[derive(Debug, Default, Serialize)] pub struct OzoneDensityCharacteristic(Characteristic); impl OzoneDensityCharacteristic { /// Creates a new Ozone Density characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::OzoneDensity, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::MicrogramsPerCubicMeter), max_value: Some(1000 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for OzoneDensityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for OzoneDensityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for OzoneDensityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for OzoneDensityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/pair_setup.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Pair Setup characteristic. #[derive(Debug, Default, Serialize)] pub struct PairSetupCharacteristic(Characteristic>); impl PairSetupCharacteristic { /// Creates a new Pair Setup characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::PairSetup, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PairSetupCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PairSetupCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for PairSetupCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for PairSetupCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/pair_verify.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Pair Verify characteristic. #[derive(Debug, Default, Serialize)] pub struct PairVerifyCharacteristic(Characteristic>); impl PairVerifyCharacteristic { /// Creates a new Pair Verify characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::PairVerify, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PairVerifyCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PairVerifyCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for PairVerifyCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for PairVerifyCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/pairing_features.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Pairing Features characteristic. #[derive(Debug, Default, Serialize)] pub struct PairingFeaturesCharacteristic(Characteristic); impl PairingFeaturesCharacteristic { /// Creates a new Pairing Features characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::PairingFeatures, format: Format::UInt8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PairingFeaturesCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PairingFeaturesCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for PairingFeaturesCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for PairingFeaturesCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/password_setting.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Password Setting characteristic. #[derive(Debug, Default, Serialize)] pub struct PasswordSettingCharacteristic(Characteristic>); impl PasswordSettingCharacteristic { /// Creates a new Password Setting characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::PasswordSetting, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PasswordSettingCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PasswordSettingCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for PasswordSettingCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for PasswordSettingCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/periodic_snapshots_active.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Periodic Snapshots Active characteristic. #[derive(Debug, Default, Serialize)] pub struct PeriodicSnapshotsActiveCharacteristic(Characteristic); impl PeriodicSnapshotsActiveCharacteristic { /// Creates a new Periodic Snapshots Active characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::PeriodicSnapshotsActive, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PeriodicSnapshotsActiveCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PeriodicSnapshotsActiveCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for PeriodicSnapshotsActiveCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for PeriodicSnapshotsActiveCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/picture_mode.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Picture Mode characteristic. #[derive(Debug, Default, Serialize)] pub struct PictureModeCharacteristic(Characteristic); impl PictureModeCharacteristic { /// Creates a new Picture Mode characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::PictureMode, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(13), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PictureModeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PictureModeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for PictureModeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for PictureModeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/ping.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Ping characteristic. #[derive(Debug, Default, Serialize)] pub struct PingCharacteristic(Characteristic>); impl PingCharacteristic { /// Creates a new Ping characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::Ping, format: Format::Data, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PingCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PingCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for PingCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for PingCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/pm10_density.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// PM10 Density characteristic. #[derive(Debug, Default, Serialize)] pub struct Pm10DensityCharacteristic(Characteristic); impl Pm10DensityCharacteristic { /// Creates a new PM10 Density characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Pm10Density, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::MicrogramsPerCubicMeter), max_value: Some(1000 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for Pm10DensityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for Pm10DensityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for Pm10DensityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for Pm10DensityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/pm2_5_density.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// PM2.5 Density characteristic. #[derive(Debug, Default, Serialize)] pub struct Pm2_5DensityCharacteristic(Characteristic); impl Pm2_5DensityCharacteristic { /// Creates a new PM2.5 Density characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Pm2_5Density, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::MicrogramsPerCubicMeter), max_value: Some(1000 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for Pm2_5DensityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for Pm2_5DensityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for Pm2_5DensityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for Pm2_5DensityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/position_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Position State characteristic. #[derive(Debug, Default, Serialize)] pub struct PositionStateCharacteristic(Characteristic); impl PositionStateCharacteristic { /// Creates a new Position State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::PositionState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PositionStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PositionStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for PositionStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for PositionStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/power_mode_selection.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Power Mode Selection characteristic. #[derive(Debug, Default, Serialize)] pub struct PowerModeSelectionCharacteristic(Characteristic); impl PowerModeSelectionCharacteristic { /// Creates a new Power Mode Selection characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::PowerModeSelection, format: Format::UInt8, perms: vec![ Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PowerModeSelectionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PowerModeSelectionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for PowerModeSelectionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for PowerModeSelectionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/power_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Power State characteristic. #[derive(Debug, Default, Serialize)] pub struct PowerStateCharacteristic(Characteristic); impl PowerStateCharacteristic { /// Creates a new Power State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::PowerState, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for PowerStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for PowerStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for PowerStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for PowerStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/product_data.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Product Data characteristic. #[derive(Debug, Default, Serialize)] pub struct ProductDataCharacteristic(Characteristic>); impl ProductDataCharacteristic { /// Creates a new Product Data characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::ProductData, format: Format::Data, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ProductDataCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ProductDataCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for ProductDataCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for ProductDataCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/program_mode.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Program Mode characteristic. #[derive(Debug, Default, Serialize)] pub struct ProgramModeCharacteristic(Characteristic); impl ProgramModeCharacteristic { /// Creates a new Program Mode characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ProgramMode, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ProgramModeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ProgramModeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ProgramModeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ProgramModeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/programmable_switch_event.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Programmable Switch Event characteristic. #[derive(Debug, Default, Serialize)] pub struct ProgrammableSwitchEventCharacteristic(Characteristic); impl ProgrammableSwitchEventCharacteristic { /// Creates a new Programmable Switch Event characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ProgrammableSwitchEvent, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ProgrammableSwitchEventCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ProgrammableSwitchEventCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ProgrammableSwitchEventCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ProgrammableSwitchEventCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/programmable_switch_output_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Programmable Switch Output State characteristic. #[derive(Debug, Default, Serialize)] pub struct ProgrammableSwitchOutputStateCharacteristic(Characteristic); impl ProgrammableSwitchOutputStateCharacteristic { /// Creates a new Programmable Switch Output State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ProgrammableSwitchOutputState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ProgrammableSwitchOutputStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ProgrammableSwitchOutputStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ProgrammableSwitchOutputStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ProgrammableSwitchOutputStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/received_signal_strength_indication.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Received Signal Strength Indication characteristic. #[derive(Debug, Default, Serialize)] pub struct ReceivedSignalStrengthIndicationCharacteristic(Characteristic); impl ReceivedSignalStrengthIndicationCharacteristic { /// Creates a new Received Signal Strength Indication characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ReceivedSignalStrengthIndication, format: Format::Int32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ReceivedSignalStrengthIndicationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ReceivedSignalStrengthIndicationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ReceivedSignalStrengthIndicationCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ReceivedSignalStrengthIndicationCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/receiver_sensitivity.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Receiver Sensitivity characteristic. #[derive(Debug, Default, Serialize)] pub struct ReceiverSensitivityCharacteristic(Characteristic); impl ReceiverSensitivityCharacteristic { /// Creates a new Receiver Sensitivity characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ReceiverSensitivity, format: Format::Int32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ReceiverSensitivityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ReceiverSensitivityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ReceiverSensitivityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ReceiverSensitivityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/recording_audio_active.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// recording audio active characteristic. #[derive(Debug, Default, Serialize)] pub struct RecordingAudioActiveCharacteristic(Characteristic); impl RecordingAudioActiveCharacteristic { /// Creates a new recording audio active characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::RecordingAudioActive, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for RecordingAudioActiveCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for RecordingAudioActiveCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for RecordingAudioActiveCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for RecordingAudioActiveCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/relative_humidity_dehumidifier_threshold.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Relative Humidity Dehumidifier Threshold characteristic. #[derive(Debug, Default, Serialize)] pub struct RelativeHumidityDehumidifierThresholdCharacteristic(Characteristic); impl RelativeHumidityDehumidifierThresholdCharacteristic { /// Creates a new Relative Humidity Dehumidifier Threshold characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::RelativeHumidityDehumidifierThreshold, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Percentage), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for RelativeHumidityDehumidifierThresholdCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for RelativeHumidityDehumidifierThresholdCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for RelativeHumidityDehumidifierThresholdCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for RelativeHumidityDehumidifierThresholdCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/relative_humidity_humidifier_threshold.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Relative Humidity Humidifier Threshold characteristic. #[derive(Debug, Default, Serialize)] pub struct RelativeHumidityHumidifierThresholdCharacteristic(Characteristic); impl RelativeHumidityHumidifierThresholdCharacteristic { /// Creates a new Relative Humidity Humidifier Threshold characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::RelativeHumidityHumidifierThreshold, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Percentage), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for RelativeHumidityHumidifierThresholdCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for RelativeHumidityHumidifierThresholdCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for RelativeHumidityHumidifierThresholdCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for RelativeHumidityHumidifierThresholdCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/remaining_duration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Remaining Duration characteristic. #[derive(Debug, Default, Serialize)] pub struct RemainingDurationCharacteristic(Characteristic); impl RemainingDurationCharacteristic { /// Creates a new Remaining Duration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::RemainingDuration, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::Seconds), max_value: Some(3600), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for RemainingDurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for RemainingDurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for RemainingDurationCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for RemainingDurationCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/remote_key.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Remote Key characteristic. #[derive(Debug, Default, Serialize)] pub struct RemoteKeyCharacteristic(Characteristic); impl RemoteKeyCharacteristic { /// Creates a new Remote Key characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::RemoteKey, format: Format::UInt8, perms: vec![ Perm::PairedWrite, ], max_value: Some(16), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for RemoteKeyCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for RemoteKeyCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for RemoteKeyCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for RemoteKeyCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/rotation_direction.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Rotation Direction characteristic. #[derive(Debug, Default, Serialize)] pub struct RotationDirectionCharacteristic(Characteristic); pub enum Value { Clockwise = 0, Counterclockwise = 1, } impl RotationDirectionCharacteristic { /// Creates a new Rotation Direction characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::RotationDirection, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // CLOCKWISE 1, // COUNTERCLOCKWISE ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for RotationDirectionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for RotationDirectionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for RotationDirectionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for RotationDirectionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/rotation_speed.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Rotation Speed characteristic. #[derive(Debug, Default, Serialize)] pub struct RotationSpeedCharacteristic(Characteristic); impl RotationSpeedCharacteristic { /// Creates a new Rotation Speed characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::RotationSpeed, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for RotationSpeedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for RotationSpeedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for RotationSpeedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for RotationSpeedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/router_status.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Router Status characteristic. #[derive(Debug, Default, Serialize)] pub struct RouterStatusCharacteristic(Characteristic); impl RouterStatusCharacteristic { /// Creates a new Router Status characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::RouterStatus, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for RouterStatusCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for RouterStatusCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for RouterStatusCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for RouterStatusCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/saturation.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Saturation characteristic. #[derive(Debug, Default, Serialize)] pub struct SaturationCharacteristic(Characteristic); impl SaturationCharacteristic { /// Creates a new Saturation characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Saturation, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Percentage), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SaturationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SaturationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SaturationCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SaturationCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/security_system_alarm_type.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Security System Alarm Type characteristic. #[derive(Debug, Default, Serialize)] pub struct SecuritySystemAlarmTypeCharacteristic(Characteristic); impl SecuritySystemAlarmTypeCharacteristic { /// Creates a new Security System Alarm Type characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SecuritySystemAlarmType, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SecuritySystemAlarmTypeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SecuritySystemAlarmTypeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SecuritySystemAlarmTypeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SecuritySystemAlarmTypeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/security_system_current_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Security System Current State characteristic. #[derive(Debug, Default, Serialize)] pub struct SecuritySystemCurrentStateCharacteristic(Characteristic); pub enum Value { StayArm = 0, AwayArm = 1, NightArm = 2, Disarm = 3, AlarmTriggered = 4, } impl SecuritySystemCurrentStateCharacteristic { /// Creates a new Security System Current State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SecuritySystemCurrentState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(4), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // STAY_ARM 1, // AWAY_ARM 2, // NIGHT_ARM 3, // DISARM 4, // ALARM_TRIGGERED ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SecuritySystemCurrentStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SecuritySystemCurrentStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SecuritySystemCurrentStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SecuritySystemCurrentStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/security_system_target_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Security System Target State characteristic. #[derive(Debug, Default, Serialize)] pub struct SecuritySystemTargetStateCharacteristic(Characteristic); pub enum Value { StayArm = 0, AwayArm = 1, NightArm = 2, Disarm = 3, AlarmTriggered = 4, } impl SecuritySystemTargetStateCharacteristic { /// Creates a new Security System Target State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SecuritySystemTargetState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // STAY_ARM 1, // AWAY_ARM 2, // NIGHT_ARM 3, // DISARM 4, // ALARM_TRIGGERED ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SecuritySystemTargetStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SecuritySystemTargetStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SecuritySystemTargetStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SecuritySystemTargetStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/selected_audio_stream_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Selected Audio Stream Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SelectedAudioStreamConfigurationCharacteristic(Characteristic>); impl SelectedAudioStreamConfigurationCharacteristic { /// Creates a new Selected Audio Stream Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SelectedAudioStreamConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SelectedAudioStreamConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SelectedAudioStreamConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SelectedAudioStreamConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SelectedAudioStreamConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/selected_camera_recording_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Selected Camera Recording Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SelectedCameraRecordingConfigurationCharacteristic(Characteristic>); impl SelectedCameraRecordingConfigurationCharacteristic { /// Creates a new Selected Camera Recording Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SelectedCameraRecordingConfiguration, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SelectedCameraRecordingConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SelectedCameraRecordingConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SelectedCameraRecordingConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SelectedCameraRecordingConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/selected_diagnostics_modes.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Selected Diagnostics Modes characteristic. #[derive(Debug, Default, Serialize)] pub struct SelectedDiagnosticsModesCharacteristic(Characteristic); impl SelectedDiagnosticsModesCharacteristic { /// Creates a new Selected Diagnostics Modes characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SelectedDiagnosticsModes, format: Format::UInt32, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SelectedDiagnosticsModesCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SelectedDiagnosticsModesCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SelectedDiagnosticsModesCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SelectedDiagnosticsModesCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/selected_stream_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Selected Stream Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SelectedStreamConfigurationCharacteristic(Characteristic>); impl SelectedStreamConfigurationCharacteristic { /// Creates a new Selected Stream Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SelectedStreamConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SelectedStreamConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SelectedStreamConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SelectedStreamConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SelectedStreamConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/serial_number.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Serial Number characteristic. #[derive(Debug, Default, Serialize)] pub struct SerialNumberCharacteristic(Characteristic); impl SerialNumberCharacteristic { /// Creates a new Serial Number characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SerialNumber, format: Format::String, perms: vec![ Perm::PairedRead, ], max_len: Some(64), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SerialNumberCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SerialNumberCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SerialNumberCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SerialNumberCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/service_signature.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Service Signature characteristic. #[derive(Debug, Default, Serialize)] pub struct ServiceSignatureCharacteristic(Characteristic>); impl ServiceSignatureCharacteristic { /// Creates a new Service Signature characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::ServiceSignature, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ServiceSignatureCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ServiceSignatureCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for ServiceSignatureCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for ServiceSignatureCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/set_duration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Set Duration characteristic. #[derive(Debug, Default, Serialize)] pub struct SetDurationCharacteristic(Characteristic); impl SetDurationCharacteristic { /// Creates a new Set Duration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SetDuration, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Seconds), max_value: Some(3600), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SetDurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SetDurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SetDurationCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SetDurationCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/setup_data_stream_transport.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Setup Data Stream Transport characteristic. #[derive(Debug, Default, Serialize)] pub struct SetupDataStreamTransportCharacteristic(Characteristic>); impl SetupDataStreamTransportCharacteristic { /// Creates a new Setup Data Stream Transport characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SetupDataStreamTransport, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SetupDataStreamTransportCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SetupDataStreamTransportCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SetupDataStreamTransportCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SetupDataStreamTransportCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/setup_endpoint.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Setup Endpoint characteristic. #[derive(Debug, Default, Serialize)] pub struct SetupEndpointCharacteristic(Characteristic>); impl SetupEndpointCharacteristic { /// Creates a new Setup Endpoint characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SetupEndpoint, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SetupEndpointCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SetupEndpointCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SetupEndpointCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SetupEndpointCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/setup_transfer_transport.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Setup Transfer Transport characteristic. #[derive(Debug, Default, Serialize)] pub struct SetupTransferTransportCharacteristic(Characteristic>); impl SetupTransferTransportCharacteristic { /// Creates a new Setup Transfer Transport characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SetupTransferTransport, format: Format::Tlv8, perms: vec![ Perm::PairedWrite, Perm::WriteResponse, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SetupTransferTransportCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SetupTransferTransportCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SetupTransferTransportCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SetupTransferTransportCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/signal_to_noise_ratio.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Signal-to-noise Ratio characteristic. #[derive(Debug, Default, Serialize)] pub struct SignalToNoiseRatioCharacteristic(Characteristic); impl SignalToNoiseRatioCharacteristic { /// Creates a new Signal-to-noise Ratio characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SignalToNoiseRatio, format: Format::Int32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SignalToNoiseRatioCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SignalToNoiseRatioCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SignalToNoiseRatioCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SignalToNoiseRatioCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/siri_enable.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Siri Enable characteristic. #[derive(Debug, Default, Serialize)] pub struct SiriEnableCharacteristic(Characteristic); impl SiriEnableCharacteristic { /// Creates a new Siri Enable characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SiriEnable, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SiriEnableCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SiriEnableCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SiriEnableCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SiriEnableCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/siri_endpoint_session_status.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Siri Endpoint Session Status characteristic. #[derive(Debug, Default, Serialize)] pub struct SiriEndpointSessionStatusCharacteristic(Characteristic>); impl SiriEndpointSessionStatusCharacteristic { /// Creates a new Siri Endpoint Session Status characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SiriEndpointSessionStatus, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SiriEndpointSessionStatusCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SiriEndpointSessionStatusCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SiriEndpointSessionStatusCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SiriEndpointSessionStatusCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/siri_engine_version.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Siri Engine Version characteristic. #[derive(Debug, Default, Serialize)] pub struct SiriEngineVersionCharacteristic(Characteristic); impl SiriEngineVersionCharacteristic { /// Creates a new Siri Engine Version characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SiriEngineVersion, format: Format::String, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SiriEngineVersionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SiriEngineVersionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SiriEngineVersionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SiriEngineVersionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/siri_input_type.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Siri Input Type characteristic. #[derive(Debug, Default, Serialize)] pub struct SiriInputTypeCharacteristic(Characteristic); impl SiriInputTypeCharacteristic { /// Creates a new Siri Input Type characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SiriInputType, format: Format::UInt8, perms: vec![ Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SiriInputTypeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SiriInputTypeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SiriInputTypeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SiriInputTypeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/siri_light_on_use.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Siri Light On Use characteristic. #[derive(Debug, Default, Serialize)] pub struct SiriLightOnUseCharacteristic(Characteristic); impl SiriLightOnUseCharacteristic { /// Creates a new Siri Light On Use characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SiriLightOnUse, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SiriLightOnUseCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SiriLightOnUseCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SiriLightOnUseCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SiriLightOnUseCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/siri_listening.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Siri Listening characteristic. #[derive(Debug, Default, Serialize)] pub struct SiriListeningCharacteristic(Characteristic); impl SiriListeningCharacteristic { /// Creates a new Siri Listening characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SiriListening, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SiriListeningCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SiriListeningCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SiriListeningCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SiriListeningCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/siri_touch_to_use.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Siri Touch To Use characteristic. #[derive(Debug, Default, Serialize)] pub struct SiriTouchToUseCharacteristic(Characteristic); impl SiriTouchToUseCharacteristic { /// Creates a new Siri Touch To Use characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SiriTouchToUse, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SiriTouchToUseCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SiriTouchToUseCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SiriTouchToUseCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SiriTouchToUseCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/slat_type.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Slat Type characteristic. #[derive(Debug, Default, Serialize)] pub struct SlatTypeCharacteristic(Characteristic); impl SlatTypeCharacteristic { /// Creates a new Slat Type characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SlatType, format: Format::UInt8, perms: vec![ Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SlatTypeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SlatTypeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SlatTypeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SlatTypeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/sleep_discovery_mode.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Sleep Discovery Mode characteristic. #[derive(Debug, Default, Serialize)] pub struct SleepDiscoveryModeCharacteristic(Characteristic); impl SleepDiscoveryModeCharacteristic { /// Creates a new Sleep Discovery Mode characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SleepDiscoveryMode, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SleepDiscoveryModeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SleepDiscoveryModeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SleepDiscoveryModeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SleepDiscoveryModeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/sleep_interval.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Sleep Interval characteristic. #[derive(Debug, Default, Serialize)] pub struct SleepIntervalCharacteristic(Characteristic); impl SleepIntervalCharacteristic { /// Creates a new Sleep Interval characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SleepInterval, format: Format::UInt32, perms: vec![ Perm::Events, Perm::PairedRead, ], min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SleepIntervalCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SleepIntervalCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SleepIntervalCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SleepIntervalCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/smoke_detected.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Smoke Detected characteristic. #[derive(Debug, Default, Serialize)] pub struct SmokeDetectedCharacteristic(Characteristic); impl SmokeDetectedCharacteristic { /// Creates a new Smoke Detected characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SmokeDetected, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SmokeDetectedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SmokeDetectedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SmokeDetectedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SmokeDetectedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/software_revision.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Software Revision characteristic. #[derive(Debug, Default, Serialize)] pub struct SoftwareRevisionCharacteristic(Characteristic); impl SoftwareRevisionCharacteristic { /// Creates a new Software Revision characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SoftwareRevision, format: Format::String, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SoftwareRevisionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SoftwareRevisionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SoftwareRevisionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SoftwareRevisionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/staged_firmware_version.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Staged Firmware Version characteristic. #[derive(Debug, Default, Serialize)] pub struct StagedFirmwareVersionCharacteristic(Characteristic); impl StagedFirmwareVersionCharacteristic { /// Creates a new Staged Firmware Version characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::StagedFirmwareVersion, format: Format::String, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for StagedFirmwareVersionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for StagedFirmwareVersionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for StagedFirmwareVersionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for StagedFirmwareVersionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/status_active.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Status Active characteristic. #[derive(Debug, Default, Serialize)] pub struct StatusActiveCharacteristic(Characteristic); impl StatusActiveCharacteristic { /// Creates a new Status Active characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::StatusActive, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for StatusActiveCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for StatusActiveCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for StatusActiveCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for StatusActiveCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/status_fault.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Status Fault characteristic. #[derive(Debug, Default, Serialize)] pub struct StatusFaultCharacteristic(Characteristic); impl StatusFaultCharacteristic { /// Creates a new Status Fault characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::StatusFault, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for StatusFaultCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for StatusFaultCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for StatusFaultCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for StatusFaultCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/status_jammed.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Status Jammed characteristic. #[derive(Debug, Default, Serialize)] pub struct StatusJammedCharacteristic(Characteristic); impl StatusJammedCharacteristic { /// Creates a new Status Jammed characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::StatusJammed, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for StatusJammedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for StatusJammedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for StatusJammedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for StatusJammedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/status_low_battery.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Status Low Battery characteristic. #[derive(Debug, Default, Serialize)] pub struct StatusLowBatteryCharacteristic(Characteristic); pub enum Value { BatteryNormal = 0, BatteryLow = 1, } impl StatusLowBatteryCharacteristic { /// Creates a new Status Low Battery characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::StatusLowBattery, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // BATTERY_NORMAL 1, // BATTERY_LOW ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for StatusLowBatteryCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for StatusLowBatteryCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for StatusLowBatteryCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for StatusLowBatteryCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/status_tampered.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Status Tampered characteristic. #[derive(Debug, Default, Serialize)] pub struct StatusTamperedCharacteristic(Characteristic); impl StatusTamperedCharacteristic { /// Creates a new Status Tampered characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::StatusTampered, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for StatusTamperedCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for StatusTamperedCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for StatusTamperedCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for StatusTamperedCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/streaming_status.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Streaming Status characteristic. #[derive(Debug, Default, Serialize)] pub struct StreamingStatusCharacteristic(Characteristic>); impl StreamingStatusCharacteristic { /// Creates a new Streaming Status characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::StreamingStatus, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for StreamingStatusCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for StreamingStatusCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for StreamingStatusCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for StreamingStatusCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/sulphur_dioxide_density.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Sulphur dioxide Density characteristic. #[derive(Debug, Default, Serialize)] pub struct SulphurDioxideDensityCharacteristic(Characteristic); impl SulphurDioxideDensityCharacteristic { /// Creates a new Sulphur dioxide Density characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SulphurDioxideDensity, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::MicrogramsPerCubicMeter), max_value: Some(1000 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SulphurDioxideDensityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SulphurDioxideDensityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SulphurDioxideDensityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SulphurDioxideDensityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_asset_types.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Asset Types characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedAssetTypesCharacteristic(Characteristic); impl SupportedAssetTypesCharacteristic { /// Creates a new Supported Asset Types characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SupportedAssetTypes, format: Format::UInt32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedAssetTypesCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedAssetTypesCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SupportedAssetTypesCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SupportedAssetTypesCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_audio_recording_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Audio Recording Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedAudioRecordingConfigurationCharacteristic(Characteristic>); impl SupportedAudioRecordingConfigurationCharacteristic { /// Creates a new Supported Audio Recording Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedAudioRecordingConfiguration, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedAudioRecordingConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedAudioRecordingConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedAudioRecordingConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedAudioRecordingConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_audio_stream_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Audio Stream Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedAudioStreamConfigurationCharacteristic(Characteristic>); impl SupportedAudioStreamConfigurationCharacteristic { /// Creates a new Supported Audio Stream Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedAudioStreamConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedAudioStreamConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedAudioStreamConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedAudioStreamConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedAudioStreamConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_camera_recording_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Camera Recording Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedCameraRecordingConfigurationCharacteristic(Characteristic>); impl SupportedCameraRecordingConfigurationCharacteristic { /// Creates a new Supported Camera Recording Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedCameraRecordingConfiguration, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedCameraRecordingConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedCameraRecordingConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedCameraRecordingConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedCameraRecordingConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_characteristic_value_transition_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Characteristic Value Transition Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedCharacteristicValueTransitionConfigurationCharacteristic(Characteristic>); impl SupportedCharacteristicValueTransitionConfigurationCharacteristic { /// Creates a new Supported Characteristic Value Transition Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedCharacteristicValueTransitionConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedCharacteristicValueTransitionConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedCharacteristicValueTransitionConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedCharacteristicValueTransitionConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedCharacteristicValueTransitionConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_data_stream_transport_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Data Stream Transport Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedDataStreamTransportConfigurationCharacteristic(Characteristic>); impl SupportedDataStreamTransportConfigurationCharacteristic { /// Creates a new Supported Data Stream Transport Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedDataStreamTransportConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedDataStreamTransportConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedDataStreamTransportConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedDataStreamTransportConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedDataStreamTransportConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_diagnostics_modes.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Diagnostics Modes characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedDiagnosticsModesCharacteristic(Characteristic); impl SupportedDiagnosticsModesCharacteristic { /// Creates a new Supported Diagnostics Modes characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SupportedDiagnosticsModes, format: Format::UInt32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedDiagnosticsModesCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedDiagnosticsModesCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SupportedDiagnosticsModesCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SupportedDiagnosticsModesCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_diagnostics_snapshot.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Diagnostics Snapshot characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedDiagnosticsSnapshotCharacteristic(Characteristic>); impl SupportedDiagnosticsSnapshotCharacteristic { /// Creates a new Supported Diagnostics Snapshot characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedDiagnosticsSnapshot, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedDiagnosticsSnapshotCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedDiagnosticsSnapshotCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedDiagnosticsSnapshotCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedDiagnosticsSnapshotCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_firmware_update_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Firmware Update Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedFirmwareUpdateConfigurationCharacteristic(Characteristic>); impl SupportedFirmwareUpdateConfigurationCharacteristic { /// Creates a new Supported Firmware Update Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedFirmwareUpdateConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedFirmwareUpdateConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedFirmwareUpdateConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedFirmwareUpdateConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedFirmwareUpdateConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_router_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Router Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedRouterConfigurationCharacteristic(Characteristic>); impl SupportedRouterConfigurationCharacteristic { /// Creates a new Supported Router Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedRouterConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedRouterConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedRouterConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedRouterConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedRouterConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_rtp_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported RTP Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedRtpConfigurationCharacteristic(Characteristic>); impl SupportedRtpConfigurationCharacteristic { /// Creates a new Supported RTP Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedRtpConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedRtpConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedRtpConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedRtpConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedRtpConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_target_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Target Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedTargetConfigurationCharacteristic(Characteristic>); impl SupportedTargetConfigurationCharacteristic { /// Creates a new Supported Target Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedTargetConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedTargetConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedTargetConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedTargetConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedTargetConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_transfer_transport_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Transfer Transport Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedTransferTransportConfigurationCharacteristic(Characteristic>); impl SupportedTransferTransportConfigurationCharacteristic { /// Creates a new Supported Transfer Transport Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedTransferTransportConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedTransferTransportConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedTransferTransportConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedTransferTransportConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedTransferTransportConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_video_recording_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Video Recording Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedVideoRecordingConfigurationCharacteristic(Characteristic>); impl SupportedVideoRecordingConfigurationCharacteristic { /// Creates a new Supported Video Recording Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedVideoRecordingConfiguration, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedVideoRecordingConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedVideoRecordingConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedVideoRecordingConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedVideoRecordingConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/supported_video_stream_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Supported Video Stream Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct SupportedVideoStreamConfigurationCharacteristic(Characteristic>); impl SupportedVideoStreamConfigurationCharacteristic { /// Creates a new Supported Video Stream Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::SupportedVideoStreamConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SupportedVideoStreamConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SupportedVideoStreamConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for SupportedVideoStreamConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for SupportedVideoStreamConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/swing_mode.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Swing Mode characteristic. #[derive(Debug, Default, Serialize)] pub struct SwingModeCharacteristic(Characteristic); impl SwingModeCharacteristic { /// Creates a new Swing Mode characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::SwingMode, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for SwingModeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for SwingModeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for SwingModeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for SwingModeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_air_purifier_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Air Purifier State characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetAirPurifierStateCharacteristic(Characteristic); pub enum Value { Manual = 0, Auto = 1, } impl TargetAirPurifierStateCharacteristic { /// Creates a new Target Air Purifier State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetAirPurifierState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // MANUAL 1, // AUTO ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetAirPurifierStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetAirPurifierStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetAirPurifierStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetAirPurifierStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_door_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Door State characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetDoorStateCharacteristic(Characteristic); pub enum Value { Num1 = 0, Num0 = 1, } impl TargetDoorStateCharacteristic { /// Creates a new Target Door State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetDoorState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // 1 1, // 0 ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetDoorStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetDoorStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetDoorStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetDoorStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_fan_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Fan State characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetFanStateCharacteristic(Characteristic); pub enum Value { Manual = 0, Auto = 1, } impl TargetFanStateCharacteristic { /// Creates a new Target Fan State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetFanState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // MANUAL 1, // AUTO ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetFanStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetFanStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetFanStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetFanStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_heater_cooler_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Heater-Cooler State characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetHeaterCoolerStateCharacteristic(Characteristic); pub enum Value { Auto = 0, HeatAuto = 1, CoolAuto = 2, } impl TargetHeaterCoolerStateCharacteristic { /// Creates a new Target Heater-Cooler State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetHeaterCoolerState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // AUTO 1, // HEAT_AUTO 2, // COOL_AUTO ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetHeaterCoolerStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetHeaterCoolerStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetHeaterCoolerStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetHeaterCoolerStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_heating_cooling_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Heating Cooling State characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetHeatingCoolingStateCharacteristic(Characteristic); pub enum Value { Off = 0, Heat = 1, Cool = 2, Auto = 3, } impl TargetHeatingCoolingStateCharacteristic { /// Creates a new Target Heating Cooling State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetHeatingCoolingState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // OFF 1, // HEAT 2, // COOL 3, // AUTO ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetHeatingCoolingStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetHeatingCoolingStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetHeatingCoolingStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetHeatingCoolingStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_horizontal_tilt_angle.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Horizontal Tilt Angle characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetHorizontalTiltAngleCharacteristic(Characteristic); impl TargetHorizontalTiltAngleCharacteristic { /// Creates a new Target Horizontal Tilt Angle characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetHorizontalTiltAngle, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::ArcDegrees), max_value: Some(90), min_value: Some(-90), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetHorizontalTiltAngleCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetHorizontalTiltAngleCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetHorizontalTiltAngleCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetHorizontalTiltAngleCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_humidifier_dehumidifier_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Humidifier-Dehumidifier State characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetHumidifierDehumidifierStateCharacteristic(Characteristic); pub enum Value { Auto = 0, HumidifyAuto = 1, DehumidifyAuto = 2, } impl TargetHumidifierDehumidifierStateCharacteristic { /// Creates a new Target Humidifier-Dehumidifier State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetHumidifierDehumidifierState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), valid_values: Some(vec![ 0, // AUTO 1, // HUMIDIFY_AUTO 2, // DEHUMIDIFY_AUTO ]), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetHumidifierDehumidifierStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetHumidifierDehumidifierStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetHumidifierDehumidifierStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetHumidifierDehumidifierStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_list_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target List Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetListConfigurationCharacteristic(Characteristic>); impl TargetListConfigurationCharacteristic { /// Creates a new Target List Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::TargetListConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, Perm::PairedWrite, Perm::WriteResponse, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetListConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetListConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for TargetListConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for TargetListConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_media_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Media State characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetMediaStateCharacteristic(Characteristic); impl TargetMediaStateCharacteristic { /// Creates a new Target Media State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetMediaState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(2), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetMediaStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetMediaStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetMediaStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetMediaStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_position.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Position characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetPositionCharacteristic(Characteristic); impl TargetPositionCharacteristic { /// Creates a new Target Position characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetPosition, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Percentage), max_value: Some(100), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetPositionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetPositionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetPositionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetPositionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_relative_humidity.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Relative Humidity characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetRelativeHumidityCharacteristic(Characteristic); impl TargetRelativeHumidityCharacteristic { /// Creates a new Target Relative Humidity characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetRelativeHumidity, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Percentage), max_value: Some(100 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetRelativeHumidityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetRelativeHumidityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetRelativeHumidityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetRelativeHumidityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_temperature.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Temperature characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetTemperatureCharacteristic(Characteristic); impl TargetTemperatureCharacteristic { /// Creates a new Target Temperature characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetTemperature, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Celsius), max_value: Some(38 as f32), min_value: Some(10 as f32), step_value: Some(0.1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetTemperatureCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetTemperatureCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetTemperatureCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetTemperatureCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_tilt_angle.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Tilt Angle characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetTiltAngleCharacteristic(Characteristic); impl TargetTiltAngleCharacteristic { /// Creates a new Target Tilt Angle characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetTiltAngle, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::ArcDegrees), max_value: Some(90), min_value: Some(-90), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetTiltAngleCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetTiltAngleCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetTiltAngleCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetTiltAngleCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_vertical_tilt_angle.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Vertical Tilt Angle characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetVerticalTiltAngleCharacteristic(Characteristic); impl TargetVerticalTiltAngleCharacteristic { /// Creates a new Target Vertical Tilt Angle characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetVerticalTiltAngle, format: Format::Int32, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::ArcDegrees), max_value: Some(90), min_value: Some(-90), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetVerticalTiltAngleCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetVerticalTiltAngleCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetVerticalTiltAngleCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetVerticalTiltAngleCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/target_visibility_state.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Target Visibility State characteristic. #[derive(Debug, Default, Serialize)] pub struct TargetVisibilityStateCharacteristic(Characteristic); impl TargetVisibilityStateCharacteristic { /// Creates a new Target Visibility State characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TargetVisibilityState, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TargetVisibilityStateCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TargetVisibilityStateCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TargetVisibilityStateCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TargetVisibilityStateCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/temperature_display_units.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Temperature Display Units characteristic. #[derive(Debug, Default, Serialize)] pub struct TemperatureDisplayUnitsCharacteristic(Characteristic); impl TemperatureDisplayUnitsCharacteristic { /// Creates a new Temperature Display Units characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TemperatureDisplayUnits, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TemperatureDisplayUnitsCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TemperatureDisplayUnitsCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TemperatureDisplayUnitsCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TemperatureDisplayUnitsCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/third_party_camera_active.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Third Party Camera Active characteristic. #[derive(Debug, Default, Serialize)] pub struct ThirdPartyCameraActiveCharacteristic(Characteristic); impl ThirdPartyCameraActiveCharacteristic { /// Creates a new Third Party Camera Active characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ThirdPartyCameraActive, format: Format::Bool, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ThirdPartyCameraActiveCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ThirdPartyCameraActiveCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ThirdPartyCameraActiveCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ThirdPartyCameraActiveCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/thread_control_point.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Thread Control Point characteristic. #[derive(Debug, Default, Serialize)] pub struct ThreadControlPointCharacteristic(Characteristic>); impl ThreadControlPointCharacteristic { /// Creates a new Thread Control Point characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::ThreadControlPoint, format: Format::Tlv8, perms: vec![ Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ThreadControlPointCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ThreadControlPointCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for ThreadControlPointCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for ThreadControlPointCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/thread_node_capabilities.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Thread Node Capabilities characteristic. #[derive(Debug, Default, Serialize)] pub struct ThreadNodeCapabilitiesCharacteristic(Characteristic); impl ThreadNodeCapabilitiesCharacteristic { /// Creates a new Thread Node Capabilities characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ThreadNodeCapabilities, format: Format::UInt16, perms: vec![ Perm::PairedRead, ], max_value: Some(31), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ThreadNodeCapabilitiesCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ThreadNodeCapabilitiesCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ThreadNodeCapabilitiesCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ThreadNodeCapabilitiesCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/thread_openthread_version.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Thread OpenThread Version characteristic. #[derive(Debug, Default, Serialize)] pub struct ThreadOpenthreadVersionCharacteristic(Characteristic); impl ThreadOpenthreadVersionCharacteristic { /// Creates a new Thread OpenThread Version characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ThreadOpenthreadVersion, format: Format::String, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ThreadOpenthreadVersionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ThreadOpenthreadVersionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ThreadOpenthreadVersionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ThreadOpenthreadVersionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/thread_status.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Thread Status characteristic. #[derive(Debug, Default, Serialize)] pub struct ThreadStatusCharacteristic(Characteristic); impl ThreadStatusCharacteristic { /// Creates a new Thread Status characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ThreadStatus, format: Format::UInt16, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(6), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ThreadStatusCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ThreadStatusCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ThreadStatusCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ThreadStatusCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/transmit_power.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Transmit Power characteristic. #[derive(Debug, Default, Serialize)] pub struct TransmitPowerCharacteristic(Characteristic); impl TransmitPowerCharacteristic { /// Creates a new Transmit Power characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::TransmitPower, format: Format::Int32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for TransmitPowerCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for TransmitPowerCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for TransmitPowerCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for TransmitPowerCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/valve_type.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Valve Type characteristic. #[derive(Debug, Default, Serialize)] pub struct ValveTypeCharacteristic(Characteristic); impl ValveTypeCharacteristic { /// Creates a new Valve Type characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::ValveType, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for ValveTypeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for ValveTypeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for ValveTypeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for ValveTypeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/version.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Version characteristic. #[derive(Debug, Default, Serialize)] pub struct VersionCharacteristic(Characteristic); impl VersionCharacteristic { /// Creates a new Version characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Version, format: Format::String, perms: vec![ Perm::Events, Perm::PairedRead, ], max_len: Some(64), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for VersionCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for VersionCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for VersionCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for VersionCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/video_analysis_active.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Video Analysis Active characteristic. #[derive(Debug, Default, Serialize)] pub struct VideoAnalysisActiveCharacteristic(Characteristic); impl VideoAnalysisActiveCharacteristic { /// Creates a new Video Analysis Active characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::VideoAnalysisActive, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for VideoAnalysisActiveCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for VideoAnalysisActiveCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for VideoAnalysisActiveCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for VideoAnalysisActiveCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/volatile_organic_compound_density.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Volatile Organic Compound Density characteristic. #[derive(Debug, Default, Serialize)] pub struct VolatileOrganicCompoundDensityCharacteristic(Characteristic); impl VolatileOrganicCompoundDensityCharacteristic { /// Creates a new Volatile Organic Compound Density characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::VolatileOrganicCompoundDensity, format: Format::Float, perms: vec![ Perm::Events, Perm::PairedRead, ], unit: Some(Unit::MicrogramsPerCubicMeter), max_value: Some(1000 as f32), min_value: Some(0 as f32), step_value: Some(1 as f32), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for VolatileOrganicCompoundDensityCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for VolatileOrganicCompoundDensityCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for VolatileOrganicCompoundDensityCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for VolatileOrganicCompoundDensityCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/volume.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Volume characteristic. #[derive(Debug, Default, Serialize)] pub struct VolumeCharacteristic(Characteristic); impl VolumeCharacteristic { /// Creates a new Volume characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::Volume, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, ], unit: Some(Unit::Percentage), max_value: Some(100), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for VolumeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for VolumeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for VolumeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for VolumeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/volume_control_type.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Volume Control Type characteristic. #[derive(Debug, Default, Serialize)] pub struct VolumeControlTypeCharacteristic(Characteristic); impl VolumeControlTypeCharacteristic { /// Creates a new Volume Control Type characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::VolumeControlType, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(3), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for VolumeControlTypeCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for VolumeControlTypeCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for VolumeControlTypeCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for VolumeControlTypeCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/volume_selector.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Volume Selector characteristic. #[derive(Debug, Default, Serialize)] pub struct VolumeSelectorCharacteristic(Characteristic); impl VolumeSelectorCharacteristic { /// Creates a new Volume Selector characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::VolumeSelector, format: Format::UInt8, perms: vec![ Perm::PairedWrite, ], max_value: Some(1), min_value: Some(0), step_value: Some(1), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for VolumeSelectorCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for VolumeSelectorCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for VolumeSelectorCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for VolumeSelectorCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/wake_configuration.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Wake Configuration characteristic. #[derive(Debug, Default, Serialize)] pub struct WakeConfigurationCharacteristic(Characteristic>); impl WakeConfigurationCharacteristic { /// Creates a new Wake Configuration characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::WakeConfiguration, format: Format::Tlv8, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for WakeConfigurationCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for WakeConfigurationCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for WakeConfigurationCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for WakeConfigurationCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/wan_configuration_list.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// WAN Configuration List characteristic. #[derive(Debug, Default, Serialize)] pub struct WanConfigurationListCharacteristic(Characteristic>); impl WanConfigurationListCharacteristic { /// Creates a new WAN Configuration List characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::WanConfigurationList, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for WanConfigurationListCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for WanConfigurationListCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for WanConfigurationListCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for WanConfigurationListCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/wan_status_list.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// WAN Status List characteristic. #[derive(Debug, Default, Serialize)] pub struct WanStatusListCharacteristic(Characteristic>); impl WanStatusListCharacteristic { /// Creates a new WAN Status List characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::WanStatusList, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for WanStatusListCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for WanStatusListCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for WanStatusListCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for WanStatusListCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/wi_fi_capabilities.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Wi-Fi Capabilities characteristic. #[derive(Debug, Default, Serialize)] pub struct WiFiCapabilitiesCharacteristic(Characteristic); impl WiFiCapabilitiesCharacteristic { /// Creates a new Wi-Fi Capabilities characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::WiFiCapabilities, format: Format::UInt32, perms: vec![ Perm::PairedRead, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for WiFiCapabilitiesCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for WiFiCapabilitiesCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for WiFiCapabilitiesCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for WiFiCapabilitiesCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/wi_fi_configuration_control.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Wi-Fi Configuration Control characteristic. #[derive(Debug, Default, Serialize)] pub struct WiFiConfigurationControlCharacteristic(Characteristic>); impl WiFiConfigurationControlCharacteristic { /// Creates a new Wi-Fi Configuration Control characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic::> { id, accessory_id, hap_type: HapType::WiFiConfigurationControl, format: Format::Tlv8, perms: vec![ Perm::Events, Perm::PairedRead, Perm::PairedWrite, Perm::TimedWrite, Perm::WriteResponse, ], ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for WiFiConfigurationControlCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for WiFiConfigurationControlCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks> for WiFiConfigurationControlCharacteristic { fn on_read(&mut self, f: Option>>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks> for WiFiConfigurationControlCharacteristic { fn on_read_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/generated/wi_fi_satellite_status.rs ================================================ // this file is auto-generated by hap-codegen use async_trait::async_trait; use serde::Serialize; use serde_json::json; use crate::{ characteristic::{ AsyncCharacteristicCallbacks, Characteristic, CharacteristicCallbacks, Format, HapCharacteristic, HapCharacteristicSetup, HapType, OnReadFn, OnReadFuture, OnUpdateFn, OnUpdateFuture, Perm, Unit, }, pointer, Result, }; // TODO - re-check MaximumDataLength /// Wi-Fi Satellite Status characteristic. #[derive(Debug, Default, Serialize)] pub struct WiFiSatelliteStatusCharacteristic(Characteristic); impl WiFiSatelliteStatusCharacteristic { /// Creates a new Wi-Fi Satellite Status characteristic. pub fn new(id: u64, accessory_id: u64) -> Self { #[allow(unused_mut)] let mut c = Self(Characteristic:: { id, accessory_id, hap_type: HapType::WiFiSatelliteStatus, format: Format::UInt8, perms: vec![ Perm::Events, Perm::PairedRead, ], max_value: Some(2), min_value: Some(0), ..Default::default() }); if let Some(ref min_value) = &c.0.min_value { c.0.value = min_value.clone(); } else if let Some(ref valid_values) = &c.0.valid_values { if valid_values.len() > 0 { c.0.value = valid_values[0].clone(); } } c } } #[async_trait] impl HapCharacteristic for WiFiSatelliteStatusCharacteristic { fn get_id(&self) -> u64 { HapCharacteristic::get_id(&self.0) } fn set_id(&mut self, id: u64) { HapCharacteristic::set_id(&mut self.0, id) } fn get_type(&self) -> HapType { HapCharacteristic::get_type(&self.0) } fn set_type(&mut self, hap_type: HapType) { HapCharacteristic::set_type(&mut self.0, hap_type) } fn get_format(&self) -> Format { HapCharacteristic::get_format(&self.0) } fn set_format(&mut self, format: Format) { HapCharacteristic::set_format(&mut self.0, format) } fn get_perms(&self) -> Vec { HapCharacteristic::get_perms(&self.0) } fn set_perms(&mut self, perms: Vec) { HapCharacteristic::set_perms(&mut self.0, perms) } fn get_description(&self) -> Option { HapCharacteristic::get_description(&self.0) } fn set_description(&mut self, description: Option) { HapCharacteristic::set_description(&mut self.0, description) } fn get_event_notifications(&self) -> Option { HapCharacteristic::get_event_notifications(&self.0) } fn set_event_notifications(&mut self, event_notifications: Option) { HapCharacteristic::set_event_notifications(&mut self.0, event_notifications) } async fn get_value(&mut self) -> Result { HapCharacteristic::get_value(&mut self.0).await } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { HapCharacteristic::set_value(&mut self.0, value).await } fn get_unit(&self) -> Option { HapCharacteristic::get_unit(&self.0) } fn set_unit(&mut self, unit: Option) { HapCharacteristic::set_unit(&mut self.0, unit) } fn get_max_value(&self) -> Option { HapCharacteristic::get_max_value(&self.0).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { HapCharacteristic::set_max_value(&mut self.0, max_value) } fn get_min_value(&self) -> Option { HapCharacteristic::get_min_value(&self.0).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { HapCharacteristic::set_min_value(&mut self.0, min_value) } fn get_step_value(&self) -> Option { HapCharacteristic::get_step_value(&self.0).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { HapCharacteristic::set_step_value(&mut self.0, step_value) } fn get_max_len(&self) -> Option { HapCharacteristic::get_max_len(&self.0) } fn set_max_len(&mut self, max_len: Option) { HapCharacteristic::set_max_len(&mut self.0, max_len) } fn get_max_data_len(&self) -> Option { HapCharacteristic::get_max_data_len(&self.0) } fn set_max_data_len(&mut self, max_data_len: Option) { HapCharacteristic::set_max_data_len(&mut self.0, max_data_len) } fn get_valid_values(&self) -> Option> { HapCharacteristic::get_valid_values(&self.0) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { HapCharacteristic::set_valid_values(&mut self.0, valid_values) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { HapCharacteristic::get_valid_values_range(&self.0) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { HapCharacteristic::set_valid_values_range(&mut self.0, valid_values_range) } fn get_ttl(&self) -> Option { HapCharacteristic::get_ttl(&self.0) } fn set_ttl(&mut self, ttl: Option) { HapCharacteristic::set_ttl(&mut self.0, ttl) } fn get_pid(&self) -> Option { HapCharacteristic::get_pid(&self.0) } fn set_pid(&mut self, pid: Option) { HapCharacteristic::set_pid(&mut self.0, pid) } } impl HapCharacteristicSetup for WiFiSatelliteStatusCharacteristic { fn set_event_emitter(&mut self, event_emitter: Option) { HapCharacteristicSetup::set_event_emitter(&mut self.0, event_emitter) } } impl CharacteristicCallbacks for WiFiSatelliteStatusCharacteristic { fn on_read(&mut self, f: Option>) { CharacteristicCallbacks::on_read(&mut self.0, f) } fn on_update(&mut self, f: Option>) { CharacteristicCallbacks::on_update(&mut self.0, f) } } impl AsyncCharacteristicCallbacks for WiFiSatelliteStatusCharacteristic { fn on_read_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_read_async(&mut self.0, f) } fn on_update_async(&mut self, f: Option>) { AsyncCharacteristicCallbacks::on_update_async(&mut self.0, f) } } ================================================ FILE: src/characteristic/mod.rs ================================================ use async_trait::async_trait; use erased_serde::serialize_trait_object; use futures::future::BoxFuture; use serde::{ ser::{SerializeStruct, Serializer}, Deserialize, Serialize, }; use serde_json::json; use std::fmt; use crate::{event::Event, pointer, Error, HapType, Result}; mod generated; pub use generated::*; /// A characteristic. A characteristic is a feature that represents data or an associated behavior of a service. The /// characteristic is defined by a universally unique type, and has additional properties that determine how the value /// of the characteristic can be accessed. #[derive(Default)] pub struct Characteristic { /// Instance ID; integer assigned by the server to uniquely identify the HAP characteristic object. id: u64, /// ID of the accessory the characteristic belongs to. accessory_id: u64, /// The type of the characteristic. hap_type: HapType, /// Format of the value. format: Format, /// Permissions describing the capabilities of the characteristic. perms: Vec, /// String describing the characteristic on a manufacturer-specific basis, such as an indoor versus outdoor /// temperature reading. description: Option, /// Boolean indicating if event notifications are enabled for this characteristic. event_notifications: Option, /// The value of the characteristic, which must conform to the `format` property. This property must be present if /// and only if the characteristic contains the Paired Read permission. value: T, /// Unit of the value, e.g. `Celsius`. unit: Option, /// Maximum value for the characteristic, which is only appropriate for characteristics that have a format of `Int` /// or `Float`. max_value: Option, // TODO - use this value in `set_value` // Minimum value for the characteristic, which is only appropriate for characteristics that have a format of `Int` // or `Float`. min_value: Option, // TODO - use this value in `set_value` /// Minimum step value for the characteristic, which is only appropriate for characteristics that have a format of /// ”int” or ”float”. For example, if this were 0.15, the characteris- tic value can be incremented from the min- /// imum value in multiples of 0.15. For “float”, the “Value” needs to be rounded on the ac- cessory side to the /// closest allowed value per the ”Step Value” (e.g. a value of 10.150001 received on the accessory side with a /// ”Step Value” of 0.15 and a ”Minimum Value” of 10.0 needs to be interpreted as 10.15). step_value: Option, // TODO - use this value in `set_value` /// Maximum number of characters if the for- mat is ”string”. If this property is omitted for ”string” formats, /// then the default value is 64. The maximum value allowed is 256. max_len: Option, // TODO - use this value in `set_value` /// Maximum number of characters if the format is ”data”. If this property is omitted for ”data” formats, then the /// default value is 2097152. max_data_len: Option, // TODO - use this value in `set_value` /// An array of numbers where each element represents a valid value. valid_values: Option>, // TODO - use this value in `set_value` /// A 2 element array representing the starting value and ending value of the range of valid values. valid_values_range: Option<[T; 2]>, // TODO - use this value in `set_value` /// Specified TTL in milliseconds the controller requests the accessory to securely execute a write command. /// Maximum value of this is 9007199254740991. ttl: Option, // TODO - use this value in `set_value` /// 64-bit unsigned integer assigned by the controller to uniquely identify the timed write transaction. pid: Option, // TODO - use this value in `set_value` /// Sets a callback function on a characteristic that is called every time a controller attempts to read its value. /// Returning a `Some(T)` from this function changes the value of the characteristic before the controller reads /// it so the Controller reads the new value. on_read: Option>>, /// Sets a callback function on a characteristic that is called every time a controller attempts to update its /// value. The first argument is a reference to the current value of the characteristic and the second argument is /// a reference to the value the controller attempts to change the characteristic's to. on_update: Option>>, /// Sets an async callback function on a characteristic that is driven to completion by the async runtime driving /// the HAP server every time a controller attempts to read its value. Returning a `Some(T)` from this function /// changes the value of the characteristic before the controller reads it so the controller reads the new value. on_read_async: Option>>, /// Sets an async callback function on a characteristic that is driven to completion by the async runtime driving /// the HAP server every time a controller attempts to update its value. The first argument is a reference to the /// current value of the characteristic and the second argument is a reference to the value the controller attempts /// to change the characteristic's to. on_update_async: Option>>, event_emitter: Option, } impl fmt::Debug for Characteristic { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Characteristic") .field("id", &self.id) .field("accessory_id", &self.accessory_id) .field("hap_type", &self.hap_type) .field("format", &self.format) .field("perms", &self.perms) .field("description", &self.description) .field("event_notifications", &self.event_notifications) .field("value", &self.value) .field("unit", &self.unit) .field("max_value", &self.max_value) .field("min_value", &self.min_value) .field("step_value", &self.step_value) .field("max_len", &self.max_len) .field("max_data_len", &self.max_data_len) .field("valid_values", &self.valid_values) .field("valid_values_range", &self.valid_values_range) .field("ttl", &self.ttl) .field("pid", &self.pid) .finish() } } impl Characteristic where for<'de> T: Deserialize<'de>, { /// Creates a new characteristic. pub fn new( id: u64, accessory_id: u64, hap_type: HapType, format: Format, perms: Vec, description: Option, event_notifications: Option, value: T, unit: Option, max_value: Option, min_value: Option, step_value: Option, max_len: Option, max_data_len: Option, valid_values: Option>, valid_values_range: Option<[T; 2]>, ttl: Option, pid: Option, ) -> Self { Self { id, accessory_id, hap_type, format, perms, description, event_notifications, value, unit, max_value, min_value, step_value, max_len, max_data_len, valid_values, valid_values_range, ttl, pid, on_read: None, on_update: None, on_read_async: None, on_update_async: None, event_emitter: None, } } /// Returns the ID of the characteristic. pub fn get_id(&self) -> u64 { self.id } /// Sets the ID of the characteristic. pub fn set_id(&mut self, id: u64) { self.id = id; } /// Returns the [`HapType`](HapType) of the characteristic. pub fn get_type(&self) -> HapType { self.hap_type } /// Sets the [`HapType`](HapType) of the characteristic. pub fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } /// Returns the [`Format`](Format) of the characteristic. pub fn get_format(&self) -> Format { self.format } /// Sets the [`Format`](Format) of the characteristic. pub fn set_format(&mut self, format: Format) { self.format = format; } /// Returns the [`Perm`](Perm)s of the characteristic. pub fn get_perms(&self) -> Vec { self.perms.clone() } /// Sets the [`Perm`](Perm)s of the characteristic. pub fn set_perms(&mut self, perms: Vec) { self.perms = perms; } /// Returns the description of the characteristic. pub fn get_description(&self) -> Option { self.description.clone() } /// Sets the description of the characteristic. pub fn set_description(&mut self, description: Option) { self.description = description; } /// Returns the `event_notifications` value of the characteristic. pub fn get_event_notifications(&self) -> Option { self.event_notifications } /// Sets the `event_notifications` value of the characteristic. pub fn set_event_notifications(&mut self, event_notifications: Option) { self.event_notifications = event_notifications; } /// Returns the value of the characteristic. pub async fn get_value(&mut self) -> Result { let mut val = None; if let Some(ref mut on_read) = self.on_read { val = on_read().map_err(|e| Error::ValueOnRead(e))?; } if let Some(ref mut on_read_async) = self.on_read_async { val = on_read_async().await.map_err(|e| Error::ValueOnRead(e))?; } if let Some(v) = val { self.set_value(v).await?; } Ok(self.value.clone()) } /// Sets the value of the characteristic. pub async fn set_value(&mut self, val: T) -> Result<()> { // TODO - check for min/max on types implementing PartialOrd // if let Some(ref max) = self.inner.try_borrow()?.max_value { // if &val > max { // return Err(Error::from_str("value above max_value")); // } // } // if let Some(ref min) = self.inner.try_borrow()?.min_value { // if &val < min { // return Err(Error::from_str("value below min_value")); // } // } let old_val = self.value.clone(); if let Some(ref mut on_update) = self.on_update { on_update(&old_val, &val).map_err(|e| Error::ValueOnUpdate(e))?; } if let Some(ref mut on_update_async) = self.on_update_async { on_update_async(old_val, val.clone()) .await .map_err(|e| Error::ValueOnUpdate(e))?; } if self.event_notifications == Some(true) { if let Some(ref event_emitter) = self.event_emitter { event_emitter .lock() .await .emit(&Event::CharacteristicValueChanged { aid: self.accessory_id, iid: self.id, value: json!(&val), }) .await; } } self.value = val; Ok(()) } /// Returns the [`Unit`](Unit) of the characteristic. pub fn get_unit(&self) -> Option { self.unit } /// Sets the [`Unit`](Unit) of the characteristic. pub fn set_unit(&mut self, unit: Option) { self.unit = unit; } /// Returns the maximum value of the characteristic. pub fn get_max_value(&self) -> Option { self.max_value.clone() } /// Sets the maximum value of the characteristic. pub fn set_max_value(&mut self, val: Option) { self.max_value = val; } /// Returns the minimum value of the characteristic. pub fn get_min_value(&self) -> Option { self.min_value.clone() } /// Sets the minimum value of the characteristic. pub fn set_min_value(&mut self, val: Option) { self.min_value = val; } /// Returns the step value of the characteristic. pub fn get_step_value(&self) -> Option { self.step_value.clone() } /// Sets the step value of the characteristic. pub fn set_step_value(&mut self, val: Option) { self.step_value = val; } /// Returns the maximum length of the characteristic. pub fn get_max_len(&self) -> Option { self.max_len } /// Sets the maximum length of the characteristic. pub fn set_max_len(&mut self, val: Option) { self.max_len = val; } /// Returns the maximum data length of the characteristic. pub fn get_max_data_len(&self) -> Option { self.max_data_len } /// Sets the maximum data length of the characteristic. pub fn set_max_data_len(&mut self, val: Option) { self.max_data_len = val; } /// Returns the valid values of the characteristic. pub fn get_valid_values(&self) -> Option> { self.valid_values.clone() } /// Sets the valid values of the characteristic. pub fn set_valid_values(&mut self, val: Option>) { self.valid_values = val; } /// Returns the valid values range of the characteristic. pub fn get_valid_values_range(&self) -> Option<[T; 2]> { self.valid_values_range.clone() } /// Sets the valid values range of the characteristic. pub fn set_valid_values_range(&mut self, val: Option<[T; 2]>) { self.valid_values_range = val; } /// Returns the TTL of the characteristic. pub fn get_ttl(&self) -> Option { self.ttl } /// Sets the TTL of the characteristic. pub fn set_ttl(&mut self, val: Option) { self.ttl = val; } /// Returns the PID of the characteristic. pub fn get_pid(&self) -> Option { self.pid } /// Sets the PID of the characteristic. pub fn set_pid(&mut self, val: Option) { self.pid = val; } /// Sets a callback function on a characteristic that is called every time a controller attempts to read its value. /// Returning a `Some(T)` from this function changes the value of the characteristic before the controller reads /// it so the controller reads the new value. pub fn on_read(&mut self, f: Option>) { self.on_read = f.map(|f| Box::new(f) as Box>); } /// Sets a callback function on a characteristic that is called every time a controller attempts to update its /// value. The first argument is a reference to the current value of the characteristic and the second argument is a /// reference to the value the controller attempts to change the characteristic's to. pub fn on_update(&mut self, f: Option>) { self.on_update = f.map(|f| Box::new(f) as Box>); } /// Sets an async callback function on a characteristic that is driven to completion by the async runtime driving /// the HAP server every time a controller attempts to read its value. Returning a `Some(T)` from this function /// changes the value of the characteristic before the controller reads it so the controller reads the new value. pub fn on_read_async(&mut self, f: Option>) { self.on_read_async = f.map(|f| Box::new(f) as Box>); } /// Sets an async callback function on a characteristic that is driven to completion by the async runtime driving /// the HAP server every time a controller attempts to update its value. The first argument is a reference to the /// current value of the characteristic and the second argument is a reference to the value the controller attempts /// to change the characteristic's to. pub fn on_update_async(&mut self, f: Option>) { self.on_update_async = f.map(|f| Box::new(f) as Box>); } /// Sets a pointer to an `EventEmitter` on the characteristic. pub(crate) fn set_event_emitter(&mut self, event_emitter: Option) { self.event_emitter = event_emitter; } } impl Serialize for Characteristic { fn serialize(&self, serializer: S) -> std::result::Result { let mut state = serializer.serialize_struct("Characteristic", 15)?; state.serialize_field("iid", &self.id)?; state.serialize_field("type", &self.hap_type)?; state.serialize_field("format", &self.format)?; state.serialize_field("perms", &self.perms)?; if let Some(ref description) = self.description { state.serialize_field("description", description)?; } if let Some(ref event_notifications) = self.event_notifications { state.serialize_field("ev", event_notifications)?; } if self.perms.contains(&Perm::PairedRead) { state.serialize_field("value", &self.value)?; } if let Some(ref unit) = self.unit { state.serialize_field("unit", unit)?; } if let Some(ref max_value) = self.max_value { state.serialize_field("maxValue", max_value)?; } if let Some(ref min_value) = self.min_value { state.serialize_field("minValue", min_value)?; } if let Some(ref step_value) = self.step_value { state.serialize_field("minStep", step_value)?; } if let Some(ref max_len) = self.max_len { state.serialize_field("maxLen", max_len)?; } if let Some(ref max_data_len) = self.max_data_len { state.serialize_field("maxDataLen", max_data_len)?; } if let Some(ref valid_values) = self.valid_values { state.serialize_field("valid-values", valid_values)?; } if let Some(ref valid_values_range) = self.valid_values_range { state.serialize_field("valid-values-range", valid_values_range)?; } if let Some(ref ttl) = self.ttl { state.serialize_field("TTL", ttl)?; } if let Some(ref pid) = self.pid { state.serialize_field("pid", pid)?; } state.end() } } /// Permission of a characteristic. #[derive(Debug, Copy, Clone, Serialize, PartialEq)] pub enum Perm { #[serde(rename = "pr")] PairedRead, #[serde(rename = "pw")] PairedWrite, #[serde(rename = "ev")] Events, #[serde(rename = "aa")] AdditionalAuthorization, #[serde(rename = "tw")] TimedWrite, #[serde(rename = "hd")] Hidden, #[serde(rename = "wr")] WriteResponse, } /// [`Unit`](Unit) of a characteristic. #[derive(Debug, Copy, Clone, Serialize)] pub enum Unit { #[serde(rename = "celsius")] Celsius, #[serde(rename = "fahrenheit")] Fahrenheit, #[serde(rename = "percentage")] Percentage, #[serde(rename = "arcdegrees")] ArcDegrees, #[serde(rename = "lux")] Lux, #[serde(rename = "seconds")] Seconds, #[serde(rename = "ppm")] PartsPerMillion, #[serde(rename = "micrograms/m^3")] MicrogramsPerCubicMeter, } /// [`Format`](Format) (data type) of a characteristic. #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] pub enum Format { #[serde(rename = "bool")] Bool, #[serde(rename = "uint8")] UInt8, #[serde(rename = "uint16")] UInt16, #[serde(rename = "uint32")] UInt32, #[serde(rename = "uint64")] UInt64, #[serde(rename = "int")] Int32, #[serde(rename = "float")] Float, #[serde(rename = "string")] String, #[serde(rename = "tlv8")] Tlv8, #[serde(rename = "data")] Data, } impl Default for Format { fn default() -> Format { Format::String } } /// [`HapCharacteristic`](HapCharacteristic) is implemented by every HAP characteristic. #[async_trait] pub trait HapCharacteristic: HapCharacteristicSetup + erased_serde::Serialize + Send + Sync { /// Returns the ID of the characteristic. fn get_id(&self) -> u64; /// Sets the ID of the characteristic. fn set_id(&mut self, id: u64); /// Returns the [`HapType`](HapType) of the characteristic. fn get_type(&self) -> HapType; /// Sets the [`HapType`](HapType) of the characteristic. fn set_type(&mut self, hap_type: HapType); /// Returns the [`Format`](Format) of the characteristic. fn get_format(&self) -> Format; /// Sets the [`Format`](Format) of the characteristic. fn set_format(&mut self, format: Format); /// Returns the [`Perm`](Perm)s of the characteristic. fn get_perms(&self) -> Vec; /// Sets the [`Perm`](Perm)s of the characteristic. fn set_perms(&mut self, perms: Vec); /// Returns the description of the characteristic. fn get_description(&self) -> Option; /// Sets the description of the characteristic. fn set_description(&mut self, description: Option); /// Returns the `event_notifications` value of the characteristic. fn get_event_notifications(&self) -> Option; /// Sets the `event_notifications` value of the characteristic. fn set_event_notifications(&mut self, event_notifications: Option); /// Returns the value of the characteristic. async fn get_value(&mut self) -> Result; /// Sets the value of the characteristic. async fn set_value(&mut self, value: serde_json::Value) -> Result<()>; /// Returns the [`Unit`](Unit) of the characteristic. fn get_unit(&self) -> Option; /// Sets the [`Unit`](Unit) of the characteristic. fn set_unit(&mut self, unit: Option); /// Returns the maximum value of the characteristic. fn get_max_value(&self) -> Option; /// Sets the maximum value of the characteristic. fn set_max_value(&mut self, max_value: Option) -> Result<()>; /// Returns the minimum value of the characteristic. fn get_min_value(&self) -> Option; /// Sets the minimum value of the characteristic. fn set_min_value(&mut self, min_value: Option) -> Result<()>; /// Returns the step value of the characteristic. fn get_step_value(&self) -> Option; /// Sets the step value of the characteristic. fn set_step_value(&mut self, step_value: Option) -> Result<()>; /// Returns the maximum length of the characteristic. fn get_max_len(&self) -> Option; /// Sets the maximum length of the characteristic. fn set_max_len(&mut self, max_len: Option); /// Returns the maximum data length of the characteristic. fn get_max_data_len(&self) -> Option; /// Sets the maximum data length of the characteristic. fn set_max_data_len(&mut self, max_data_len: Option); /// Returns the valid values of the characteristic. fn get_valid_values(&self) -> Option>; /// Sets the valid values of the characteristic. fn set_valid_values(&mut self, valid_values: Option>) -> Result<()>; /// Returns the valid values range of the characteristic. fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]>; /// Sets the valid values range of the characteristic. fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()>; /// Returns the TTL of the characteristic. fn get_ttl(&self) -> Option; /// Sets the TTL of the characteristic. fn set_ttl(&mut self, ttl: Option); /// Returns the PID of the characteristic. fn get_pid(&self) -> Option; /// Sets the PID of the characteristic. fn set_pid(&mut self, pid: Option); } serialize_trait_object!(HapCharacteristic); /// [`HapCharacteristicSetup`](HapCharacteristicSetup) is implemented by every HAP characteristic to provide helper /// methods used by the HAP server for setup purposes. It's not meant to be used by a consumer of the library. pub trait HapCharacteristicSetup { /// Sets a pointer to an `EventEmitter` on the characteristic. fn set_event_emitter(&mut self, event_emitter: Option); } /// [`OnReadFn`](OnReadFn) represents a callback function to be set on a characteristic that is called every time a /// controller attempts to read its value. Returning a `Some(T)` from this function changes the value of the /// characteristic before the controller reads it so the controller reads the new value. pub trait OnReadFn: Fn() -> std::result::Result, Box> + 'static + Send + Sync { } impl OnReadFn for F where F: Fn() -> std::result::Result, Box> + 'static + Send + Sync { } /// [`OnUpdateFn`](OnUpdateFn) represents a callback function to be set on a characteristic that is called every time a /// controller attempts to update its value. The first argument is a reference to the current value of the /// characteristic and the second argument is a reference to the value the controller attempts to change the /// characteristic's to. pub trait OnUpdateFn: FnMut(&T, &T) -> std::result::Result<(), Box> + 'static + Send + Sync { } impl OnUpdateFn for F where F: FnMut(&T, &T) -> std::result::Result<(), Box> + 'static + Send + Sync { } /// [`OnReadFuture`](OnReadFuture) represents an async callback function to be set on a characteristic that is driven to /// completion by the async runtime driving the HAP server every time a controller attempts to read its value. Returning /// a `Some(T)` from this function changes the value of the characteristic before the controller reads it so the /// controller reads the new value. pub trait OnReadFuture: FnMut() -> BoxFuture<'static, std::result::Result, Box>> + 'static + Send + Sync { } impl OnReadFuture for F where F: FnMut() -> BoxFuture<'static, std::result::Result, Box>> + 'static + Send + Sync { } /// [`OnUpdateFuture`](OnUpdateFuture) represents an async callback function to be set on a characteristic that is /// driven to completion by the async runtime driving the HAP server every time a controller attempts to update its /// value. The first argument is a reference to the current value of the characteristic and the second argument is a /// reference to the value the controller attempts to change the characteristic's to. pub trait OnUpdateFuture: FnMut(T, T) -> BoxFuture<'static, std::result::Result<(), Box>> + 'static + Send + Sync { } impl OnUpdateFuture for F where F: FnMut(T, T) -> BoxFuture<'static, std::result::Result<(), Box>> + 'static + Send + Sync { } /// Trait containing the [`OnReadFn`](OnReadFn) and [`OnUpdateFn`](OnUpdateFn) callback functions. pub trait CharacteristicCallbacks { /// Sets a callback function on a characteristic that is called every time a controller attempts to read its value. /// Returning a `Some(T)` from this function changes the value of the characteristic before the controller reads /// it so the controller reads the new value. fn on_read(&mut self, f: Option>); /// Sets a callback function on a characteristic that is called every time a controller attempts to update its /// value. The first argument is a reference to the current value of the characteristic and the second argument is a /// reference to the value the controller attempts to change the characteristic's to. fn on_update(&mut self, f: Option>); } /// Trait containing the [`OnReadFuture`](OnReadFuture) and [`OnUpdateFuture`](OnUpdateFuture) callback functions. pub trait AsyncCharacteristicCallbacks { /// Sets an async callback function on a characteristic that is driven to completion by the async runtime driving /// the HAP server every time a controller attempts to read its value. Returning a `Some(T)` from this function /// changes the value of the characteristic before the controller reads it so the controller reads the new value. fn on_read_async(&mut self, f: Option>); /// Sets an async callback function on a characteristic that is driven to completion by the async runtime driving /// the HAP server every time a controller attempts to update its value. The first argument is a reference to the /// current value of the characteristic and the second argument is a reference to the value the controller attempts /// to change the characteristic's to. fn on_update_async(&mut self, f: Option>); } #[async_trait] impl HapCharacteristic for Characteristic where for<'de> T: Deserialize<'de>, { fn get_id(&self) -> u64 { Characteristic::get_id(self) } fn set_id(&mut self, id: u64) { Characteristic::set_id(self, id) } fn get_type(&self) -> HapType { Characteristic::get_type(self) } fn set_type(&mut self, hap_type: HapType) { Characteristic::set_type(self, hap_type) } fn get_format(&self) -> Format { Characteristic::get_format(self) } fn set_format(&mut self, format: Format) { Characteristic::set_format(self, format) } fn get_perms(&self) -> Vec { Characteristic::get_perms(self) } fn set_perms(&mut self, perms: Vec) { Characteristic::set_perms(self, perms) } fn get_description(&self) -> Option { Characteristic::get_description(self) } fn set_description(&mut self, description: Option) { Characteristic::set_description(self, description) } fn get_event_notifications(&self) -> Option { Characteristic::get_event_notifications(self) } fn set_event_notifications(&mut self, event_notifications: Option) { Characteristic::set_event_notifications(self, event_notifications) } async fn get_value(&mut self) -> Result { let value = Characteristic::get_value(self).await?; Ok(json!(value)) } async fn set_value(&mut self, value: serde_json::Value) -> Result<()> { let v; // for whatever reason, the controller is setting boolean values either as a boolean or as an integer if self.format == Format::Bool && value.is_number() { let num_v: u8 = serde_json::from_value(value)?; if num_v == 0 { v = serde_json::from_value(json!(false))?; } else if num_v == 1 { v = serde_json::from_value(json!(true))?; } else { return Err(Error::InvalidValue(Characteristic::get_format(self))); } } else { v = serde_json::from_value(value).map_err(|_| Error::InvalidValue(Characteristic::get_format(self)))?; } Characteristic::set_value(self, v).await } fn get_unit(&self) -> Option { Characteristic::get_unit(self) } fn set_unit(&mut self, unit: Option) { Characteristic::set_unit(self, unit) } fn get_max_value(&self) -> Option { Characteristic::get_max_value(self).map(|v| json!(v)) } fn set_max_value(&mut self, max_value: Option) -> Result<()> { Characteristic::set_max_value(self, match max_value { Some(v) => Some(serde_json::from_value(v).map_err(|_| Error::InvalidValue(Characteristic::get_format(self)))?), None => None, }); Ok(()) } fn get_min_value(&self) -> Option { Characteristic::get_min_value(self).map(|v| json!(v)) } fn set_min_value(&mut self, min_value: Option) -> Result<()> { Characteristic::set_min_value(self, match min_value { Some(v) => Some(serde_json::from_value(v).map_err(|_| Error::InvalidValue(Characteristic::get_format(self)))?), None => None, }); Ok(()) } fn get_step_value(&self) -> Option { Characteristic::get_step_value(self).map(|v| json!(v)) } fn set_step_value(&mut self, step_value: Option) -> Result<()> { Characteristic::set_step_value(self, match step_value { Some(v) => Some(serde_json::from_value(v).map_err(|_| Error::InvalidValue(Characteristic::get_format(self)))?), None => None, }); Ok(()) } fn get_max_len(&self) -> Option { Characteristic::get_max_len(self) } fn set_max_len(&mut self, max_len: Option) { Characteristic::set_max_len(self, max_len) } fn get_max_data_len(&self) -> Option { Characteristic::get_max_data_len(self) } fn set_max_data_len(&mut self, max_data_len: Option) { Characteristic::set_max_data_len(self, max_data_len) } fn get_valid_values(&self) -> Option> { Characteristic::get_valid_values(self).map(|v| v.into_iter().map(|v| json!(v)).collect()) } fn set_valid_values(&mut self, valid_values: Option>) -> Result<()> { Characteristic::set_valid_values(self, match valid_values { Some(v) => Some( v.into_iter() .map(|v| { serde_json::from_value(v).map_err(|_| Error::InvalidValue(Characteristic::get_format(self))) }) .collect::>>()?, ), None => None, }); Ok(()) } fn get_valid_values_range(&self) -> Option<[serde_json::Value; 2]> { Characteristic::get_valid_values_range(self).map(|v| [json!(v[0]), json!(v[1])]) } fn set_valid_values_range(&mut self, valid_values_range: Option<[serde_json::Value; 2]>) -> Result<()> { Characteristic::set_valid_values_range(self, match valid_values_range { Some([start, end]) => Some(Result::<[T; 2]>::Ok([ serde_json::from_value(start).map_err(|_| Error::InvalidValue(Characteristic::get_format(self)))?, serde_json::from_value(end).map_err(|_| Error::InvalidValue(Characteristic::get_format(self)))?, ])?), None => None, }); Ok(()) } fn get_ttl(&self) -> Option { Characteristic::get_ttl(self) } fn set_ttl(&mut self, ttl: Option) { Characteristic::set_ttl(self, ttl) } fn get_pid(&self) -> Option { Characteristic::get_pid(self) } fn set_pid(&mut self, pid: Option) { Characteristic::set_pid(self, pid) } } impl HapCharacteristicSetup for Characteristic where for<'de> T: Deserialize<'de>, { fn set_event_emitter(&mut self, event_emitter: Option) { Characteristic::set_event_emitter(self, event_emitter) } } impl CharacteristicCallbacks for Characteristic where for<'de> T: Deserialize<'de>, { fn on_read(&mut self, f: Option>) { Characteristic::on_read(self, f) } fn on_update(&mut self, f: Option>) { Characteristic::on_update(self, f) } } impl AsyncCharacteristicCallbacks for Characteristic where for<'de> T: Deserialize<'de>, { fn on_read_async(&mut self, f: Option>) { Characteristic::on_read_async(self, f) } fn on_update_async(&mut self, f: Option>) { Characteristic::on_update_async(self, f) } } #[cfg(test)] mod tests { use super::*; #[test] fn test_json_serialization() { let characteristic = Characteristic:: { id: 1, accessory_id: 1, hap_type: HapType::CurrentTiltAngle, format: Format::UInt16, perms: vec![Perm::PairedRead, Perm::Events], description: Some("Acme Tilt Angle".into()), event_notifications: Some(true), value: 123, unit: Some(Unit::ArcDegrees), max_value: Some(360), min_value: Some(0), step_value: Some(1), max_len: None, max_data_len: None, valid_values: None, valid_values_range: Some([0, 360]), ttl: None, pid: None, on_read: None, on_update: None, on_read_async: None, on_update_async: None, event_emitter: None, }; let json = serde_json::to_string(&characteristic).unwrap(); assert_eq!(json, "{\"iid\":1,\"type\":\"C1\",\"format\":\"uint16\",\"perms\":[\"pr\",\"ev\"],\"description\":\"Acme Tilt Angle\",\"ev\":true,\"value\":123,\"unit\":\"arcdegrees\",\"maxValue\":360,\"minValue\":0,\"minStep\":1,\"valid-values-range\":[0,360]}".to_string()); } } ================================================ FILE: src/config.rs ================================================ use ed25519_dalek::Keypair as Ed25519Keypair; //use eui48::MacAddress; use macaddr::MacAddr6 as MacAddress; use rand::{rngs::OsRng, Rng}; use serde::{Deserialize, Serialize}; use std::net::IpAddr; use crate::{accessory::AccessoryCategory, BonjourFeatureFlag, BonjourStatusFlag, Pin}; /// The `Config` struct is used to store configuration options for the HomeKit Accessory Server. /// /// # Examples /// /// ``` /// use hap::{accessory::AccessoryCategory, Config, MacAddress, Pin}; /// /// let config = Config { /// pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3]).unwrap(), /// name: "Acme Lightbulb".into(), /// device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), /// category: AccessoryCategory::Lightbulb, /// ..Default::default() /// }; /// ``` #[derive(Debug, Serialize, Deserialize)] pub struct Config { /// Socket IP address to serve on. Defaults to the IP of the system's first non-loopback network interface. pub host: IpAddr, /// Port to serve on. Defaults to `32000`. pub port: u16, /// 8 digit pin used for pairing. Defaults to `11122333`. /// /// The following pins are considered too easy and are therefore not allowed: /// - `12345678` /// - `87654321` /// - `00000000` /// - `11111111` /// - `22222222` /// - `33333333` /// - `44444444` /// - `55555555` /// - `66666666` /// - `77777777` /// - `88888888` /// - `99999999` pub pin: Pin, /// Model name of the accessory. E.g. "Acme Lightbulb". pub name: String, /// Device ID of the accessory. Generated randomly if not specified. This value is also used as the accessory's /// Pairing Identifier. Must be a unique random number generated at every factory reset and must persist across /// reboots. pub device_id: MacAddress, // Bonjour: id /// pub device_ed25519_keypair: Ed25519Keypair, /// Current configuration number. Is updated when an accessory, service, or characteristic is added or removed on /// the accessory server. Accessories must increment the config number after a firmware update. pub configuration_number: u64, // Bonjour: c# /// Current state number. This must have a value of `1`. pub state_number: u8, // Bonjour: s# /// Accessory category. Indicates the category that best describes the primary function of the accessory. pub category: AccessoryCategory, // Bonjour: ci /// Protocol version string `.` (e.g. `"1.0"`). Defaults to `"1.0"` Required if value is not `"1.0"`. pub protocol_version: String, // Bonjour: pv /// Bonjour Status Flag. Defaults to `StatusFlag::NotPaired` and is changed to `StatusFlag::Zero` after a /// successful pairing. pub status_flag: BonjourStatusFlag, // Bonjour: sf /// Bonjour Feature Flag. Currently only used to indicate MFi compliance. pub feature_flag: BonjourFeatureFlag, // Bonjour: ff /// Optional maximum number of paired controllers. pub max_peers: Option, } impl Config { /// Redetermines the `host` field to the IP of the system's first non-loopback network interface. pub fn redetermine_local_ip(&mut self) { self.host = get_local_ip(); } /// Derives mDNS TXT records from the `Config`. pub(crate) fn txt_records(&self) -> [String; 8] { [ format!("c#={}", self.configuration_number), format!("ff={}", self.feature_flag as u8), format!("id={}", self.device_id.to_string()), format!("md={}", self.name), format!("pv={}", self.protocol_version), format!("s#={}", self.state_number), format!("sf={}", self.status_flag as u8), format!("ci={}", self.category as u8), // format!("sh={}", self.setup_hash as u8), setup hash seems to be still undocumented ] } } impl Default for Config { fn default() -> Config { Config { host: get_local_ip(), port: 32000, pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3]).unwrap(), name: "Accessory".into(), device_id: generate_random_mac_address(), device_ed25519_keypair: generate_ed25519_keypair(), configuration_number: 1, state_number: 1, category: AccessoryCategory::Other, protocol_version: "1.0".into(), status_flag: BonjourStatusFlag::NotPaired, feature_flag: BonjourFeatureFlag::Zero, max_peers: None, } } } /// Generates a random MAC address. fn generate_random_mac_address() -> MacAddress { let mut csprng = OsRng {}; let eui = csprng.gen::<[u8; 6]>(); MacAddress::from(eui) } /// Generates an Ed25519 keypair. fn generate_ed25519_keypair() -> Ed25519Keypair { let mut csprng = OsRng {}; Ed25519Keypair::generate(&mut csprng) } /// Returns the IP of the system's first non-loopback network interface or defaults to `127.0.0.1`. fn get_local_ip() -> IpAddr { for iface in get_if_addrs::get_if_addrs().unwrap() { if !iface.is_loopback() { return iface.ip(); } } "127.0.0.1".parse().unwrap() } ================================================ FILE: src/error.rs ================================================ use std::{io, num, str, sync::mpsc}; use thiserror::Error; use crate::characteristic::Format; /// HAP error representation. #[derive(Debug, Error)] pub enum Error { // custom errors #[error("The PIN is too easy. The following PINs are not allowed: []")] PinTooEasy, #[error("The PIN contains invalid digits. You may only use numbers from 0 to 9.")] InvalidPin, #[error( "Invalid pairing permission Byte: {0}. Only `Permissions::User = 0x00` and `Permissions::Admin = 0x01` are allowed." )] InvalidPairingPermission(u8), #[error("The value is below the `min_value` of the characteristic.")] ValueBelowMinValue, #[error("The value is above the `max_value` of the characteristic.")] ValueAboveMaxValue, #[error("The selected accessory is not present on the server.")] AccessoryNotFound, #[error("The provided accessory was already added to the server.")] DuplicateAccessory, #[error( "The provided value has an invalid data type for the characteristic. The characteristic's format is {0:?}." )] InvalidValue(Format), #[error("Invalid HapType string value: `{0}`.")] InvalidHapTypeString(String), #[error("Error on value read: {0}")] ValueOnRead(Box), #[error("Error on value update: {0}")] ValueOnUpdate(Box), #[error("Error interacting with the storage.")] Storage, // converted errors #[error("IO Error: {0}")] Io(#[from] io::Error), #[error("Serde JSON Error: {0}")] Json(#[from] serde_json::Error), #[error("HTTP Status Code: {0}")] HttpStatus(hyper::StatusCode), #[error("Hyper HTTP Error: {0}")] Http(#[from] hyper::http::Error), #[error("Hyper Error: {0}")] Hyper(#[from] hyper::Error), #[error("Task Join Error: {0}")] TaskJoin(#[from] tokio::task::JoinError), #[error("AEAD Error")] Aead, #[error("HKDF Invalid Length Error")] HkdfInvalidLength, #[error("UTF-8 Error: {0}")] Utf8(#[from] str::Utf8Error), #[error("Parse EUI-48 Error: {0}")] ParseEui48(#[from] macaddr::ParseError), #[error("Parse Int Error: {0}")] ParseInt(#[from] num::ParseIntError), #[error("MPSC Send Error: {0}")] MpscSend(#[from] mpsc::SendError<()>), } impl From for Error { fn from(_: aead::Error) -> Self { Error::Aead } } ================================================ FILE: src/event.rs ================================================ use futures::future::{join_all, BoxFuture}; use log::debug; use serde_json::Value; use std::fmt::Debug; use uuid::Uuid; #[derive(Debug)] pub enum Event { ControllerPaired { id: Uuid }, ControllerUnpaired { id: Uuid }, CharacteristicValueChanged { aid: u64, iid: u64, value: Value }, } #[derive(Default)] pub struct EventEmitter { listeners: Vec BoxFuture<()>) + Send + Sync>>, } impl EventEmitter { pub fn new() -> EventEmitter { EventEmitter { listeners: vec![] } } pub fn add_listener(&mut self, listener: Box BoxFuture<()>) + Send + Sync>) { self.listeners.push(listener); } pub async fn emit(&self, event: &Event) { debug!("emitting event: {:?}", event); join_all(self.listeners.iter().map(|listener| listener(&event))).await; } } ================================================ FILE: src/hap_type.rs ================================================ // this file is auto-generated by hap-codegen use serde::{ de::{self, Deserialize, Deserializer}, ser::{Serialize, Serializer}, }; use std::str::FromStr; use uuid::Uuid; use crate::Error; /// HAP service and characteristic type representation. #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum HapType { Unknown, Custom(Uuid), AccessCodeControlPoint, AccessCodeSupportedConfiguration, AccessControlLevel, AccessoryFlags, AccessoryIdentifier, Active, ActiveIdentifier, ActivityInterval, AdministratorOnlyAccess, AirParticulateDensity, AirParticulateSize, AirplayEnable, ApplicationMatchingIdentifier, AssetUpdateReadiness, AudioFeedback, BatteryLevel, Brightness, ButtonEvent, CcaEnergyDetectThreshold, CcaSignalDetectThreshold, CameraOperatingModeIndicator, CarbonDioxideDetected, CarbonDioxideLevel, CarbonDioxidePeakLevel, CarbonMonoxideDetected, CarbonMonoxideLevel, CarbonMonoxidePeakLevel, CharacteristicValueActiveTransitionCount, CharacteristicValueTransitionControl, ChargingState, ClosedCaptions, CloudRelayControlPoint, CloudRelayCurrentState, CloudRelayEnableStatus, ColorTemperature, ConfigurationState, ConfiguredName, ContactSensorState, CoolingThresholdTemperature, CurrentAirPurifierState, CurrentAirQuality, CurrentDoorState, CurrentFanState, CurrentHeaterCoolerState, CurrentHeatingCoolingState, CurrentHorizontalTiltAngle, CurrentHumidifierDehumidifierState, CurrentLightLevel, CurrentMediaState, CurrentPosition, CurrentRelativeHumidity, CurrentSlatState, CurrentTemperature, CurrentTiltAngle, CurrentTransport, CurrentVerticalTiltAngle, CurrentVisibilityState, CurrentWaterLevel, DataStreamHapTransport, DataStreamHapTransportInterrupt, DigitalZoom, DisplayOrder, EventRetransmissionMaximum, EventSnapshotsActive, EventTransmissionCounters, FilterChangeIndication, FilterLifeLevel, FilterResetChangeIndication, FirmwareRevision, FirmwareUpdateReadiness, FirmwareUpdateStatus, HardwareFinish, HardwareRevision, HeartBeat, HeatingThresholdTemperature, HoldPosition, HomekitCameraActive, Hue, Identifier, Identify, ImageMirroring, ImageRotation, InUse, InputDeviceType, InputSourceType, IsConfigured, LabelIndex, LabelNamespace, LeakDetected, ListPairings, LockControlPoint, LockCurrentState, LockLastKnownAction, LockManagementAutoSecurityTimeout, LockPhysicalControls, LockTargetState, Logs, MacRetransmissionMaximum, MacTransmissionCounters, ManagedNetworkEnable, ManuallyDisabled, Manufacturer, MaximumTransmitPower, Model, MotionDetected, MultifunctionButton, Mute, NfcAccessControlPoint, NfcAccessSupportedConfiguration, Name, NetworkAccessViolationControl, NetworkClientControl, NetworkClientStatusControl, NightVision, NitrogenDioxideDensity, ObstructionDetected, OccupancyDetected, OperatingStateResponse, OpticalZoom, OutletInUse, OzoneDensity, Pm10Density, Pm2_5Density, PairSetup, PairVerify, PairingFeatures, PasswordSetting, PeriodicSnapshotsActive, PictureMode, Ping, PositionState, PowerModeSelection, PowerState, ProductData, ProgramMode, ProgrammableSwitchEvent, ProgrammableSwitchOutputState, ReceivedSignalStrengthIndication, ReceiverSensitivity, RelativeHumidityDehumidifierThreshold, RelativeHumidityHumidifierThreshold, RemainingDuration, RemoteKey, RotationDirection, RotationSpeed, RouterStatus, Saturation, SecuritySystemAlarmType, SecuritySystemCurrentState, SecuritySystemTargetState, SelectedAudioStreamConfiguration, SelectedCameraRecordingConfiguration, SelectedDiagnosticsModes, SelectedStreamConfiguration, SerialNumber, ServiceSignature, SetDuration, SetupDataStreamTransport, SetupEndpoint, SetupTransferTransport, SignalToNoiseRatio, SiriEnable, SiriEndpointSessionStatus, SiriEngineVersion, SiriInputType, SiriLightOnUse, SiriListening, SiriTouchToUse, SlatType, SleepDiscoveryMode, SleepInterval, SmokeDetected, SoftwareRevision, StagedFirmwareVersion, StatusActive, StatusFault, StatusJammed, StatusLowBattery, StatusTampered, StreamingStatus, SulphurDioxideDensity, SupportedAssetTypes, SupportedAudioRecordingConfiguration, SupportedAudioStreamConfiguration, SupportedCameraRecordingConfiguration, SupportedCharacteristicValueTransitionConfiguration, SupportedDataStreamTransportConfiguration, SupportedDiagnosticsModes, SupportedDiagnosticsSnapshot, SupportedFirmwareUpdateConfiguration, SupportedRtpConfiguration, SupportedRouterConfiguration, SupportedTargetConfiguration, SupportedTransferTransportConfiguration, SupportedVideoRecordingConfiguration, SupportedVideoStreamConfiguration, SwingMode, TargetAirPurifierState, TargetDoorState, TargetFanState, TargetHeaterCoolerState, TargetHeatingCoolingState, TargetHorizontalTiltAngle, TargetHumidifierDehumidifierState, TargetListConfiguration, TargetMediaState, TargetPosition, TargetRelativeHumidity, TargetTemperature, TargetTiltAngle, TargetVerticalTiltAngle, TargetVisibilityState, TemperatureDisplayUnits, ThirdPartyCameraActive, ThreadControlPoint, ThreadNodeCapabilities, ThreadOpenthreadVersion, ThreadStatus, TransmitPower, ValveType, Version, VideoAnalysisActive, VolatileOrganicCompoundDensity, Volume, VolumeControlType, VolumeSelector, WanConfigurationList, WanStatusList, WakeConfiguration, WiFiCapabilities, WiFiConfigurationControl, WiFiSatelliteStatus, RecordingAudioActive, AccessCode, AccessControl, AccessoryInformation, AccessoryMetrics, AccessoryRuntimeInformation, AirPurifier, AirQualitySensor, AssetUpdate, Assistant, AudioStreamManagement, Battery, CameraOperatingMode, CameraRecordingManagement, CameraStreamManagement, CarbonDioxideSensor, CarbonMonoxideSensor, CloudRelay, ContactSensor, DataStreamTransportManagement, Diagnostics, Door, Doorbell, Fan, FanV2, Faucet, FilterMaintenance, GarageDoorOpener, HeaterCooler, HumidifierDehumidifier, HumiditySensor, InputSource, IrrigationSystem, Label, LeakSensor, LightSensor, Lightbulb, LockManagement, LockMechanism, Microphone, MotionSensor, NfcAccessService, OccupancySensor, Outlet, Pairing, PowerManagement, ProtocolInformation, SecuritySystem, Siri, SiriEndpoint, Slats, SmartSpeaker, SmokeSensor, Speaker, StatefulProgrammableSwitch, StatelessProgrammableSwitch, Switch, TargetControl, TargetControlManagement, Television, TemperatureSensor, Thermostat, ThreadTransport, TransferTransportManagement, Valve, WiFiRouter, WiFiSatellite, WiFiTransport, Window, WindowCovering, } impl ToString for HapType { fn to_string(&self) -> String { match self { HapType::Unknown => "unknown".into(), HapType::Custom(uuid) => uuid.to_hyphenated().to_string(), HapType::AccessCodeControlPoint => "262".into(), HapType::AccessCodeSupportedConfiguration => "261".into(), HapType::AccessControlLevel => "E5".into(), HapType::AccessoryFlags => "A6".into(), HapType::AccessoryIdentifier => "57".into(), HapType::Active => "B0".into(), HapType::ActiveIdentifier => "E7".into(), HapType::ActivityInterval => "23B".into(), HapType::AdministratorOnlyAccess => "1".into(), HapType::AirParticulateDensity => "64".into(), HapType::AirParticulateSize => "65".into(), HapType::AirplayEnable => "25B".into(), HapType::ApplicationMatchingIdentifier => "A4".into(), HapType::AssetUpdateReadiness => "269".into(), HapType::AudioFeedback => "5".into(), HapType::BatteryLevel => "68".into(), HapType::Brightness => "8".into(), HapType::ButtonEvent => "126".into(), HapType::CcaEnergyDetectThreshold => "246".into(), HapType::CcaSignalDetectThreshold => "245".into(), HapType::CameraOperatingModeIndicator => "21D".into(), HapType::CarbonDioxideDetected => "92".into(), HapType::CarbonDioxideLevel => "93".into(), HapType::CarbonDioxidePeakLevel => "94".into(), HapType::CarbonMonoxideDetected => "69".into(), HapType::CarbonMonoxideLevel => "90".into(), HapType::CarbonMonoxidePeakLevel => "91".into(), HapType::CharacteristicValueActiveTransitionCount => "24B".into(), HapType::CharacteristicValueTransitionControl => "143".into(), HapType::ChargingState => "8F".into(), HapType::ClosedCaptions => "DD".into(), HapType::CloudRelayControlPoint => "5E".into(), HapType::CloudRelayCurrentState => "5C".into(), HapType::CloudRelayEnableStatus => "5B".into(), HapType::ColorTemperature => "CE".into(), HapType::ConfigurationState => "263".into(), HapType::ConfiguredName => "E3".into(), HapType::ContactSensorState => "6A".into(), HapType::CoolingThresholdTemperature => "D".into(), HapType::CurrentAirPurifierState => "A9".into(), HapType::CurrentAirQuality => "95".into(), HapType::CurrentDoorState => "E".into(), HapType::CurrentFanState => "AF".into(), HapType::CurrentHeaterCoolerState => "B1".into(), HapType::CurrentHeatingCoolingState => "F".into(), HapType::CurrentHorizontalTiltAngle => "6C".into(), HapType::CurrentHumidifierDehumidifierState => "B3".into(), HapType::CurrentLightLevel => "6B".into(), HapType::CurrentMediaState => "E0".into(), HapType::CurrentPosition => "6D".into(), HapType::CurrentRelativeHumidity => "10".into(), HapType::CurrentSlatState => "AA".into(), HapType::CurrentTemperature => "11".into(), HapType::CurrentTiltAngle => "C1".into(), HapType::CurrentTransport => "22B".into(), HapType::CurrentVerticalTiltAngle => "6E".into(), HapType::CurrentVisibilityState => "135".into(), HapType::CurrentWaterLevel => "B5".into(), HapType::DataStreamHapTransport => "138".into(), HapType::DataStreamHapTransportInterrupt => "139".into(), HapType::DigitalZoom => "11D".into(), HapType::DisplayOrder => "136".into(), HapType::EventRetransmissionMaximum => "23D".into(), HapType::EventSnapshotsActive => "223".into(), HapType::EventTransmissionCounters => "23E".into(), HapType::FilterChangeIndication => "AC".into(), HapType::FilterLifeLevel => "AB".into(), HapType::FilterResetChangeIndication => "AD".into(), HapType::FirmwareRevision => "52".into(), HapType::FirmwareUpdateReadiness => "234".into(), HapType::FirmwareUpdateStatus => "235".into(), HapType::HardwareFinish => "26C".into(), HapType::HardwareRevision => "53".into(), HapType::HeartBeat => "24A".into(), HapType::HeatingThresholdTemperature => "12".into(), HapType::HoldPosition => "6F".into(), HapType::HomekitCameraActive => "21B".into(), HapType::Hue => "13".into(), HapType::Identifier => "E6".into(), HapType::Identify => "14".into(), HapType::ImageMirroring => "11F".into(), HapType::ImageRotation => "11E".into(), HapType::InUse => "D2".into(), HapType::InputDeviceType => "DC".into(), HapType::InputSourceType => "DB".into(), HapType::IsConfigured => "D6".into(), HapType::LabelIndex => "CB".into(), HapType::LabelNamespace => "CD".into(), HapType::LeakDetected => "70".into(), HapType::ListPairings => "50".into(), HapType::LockControlPoint => "19".into(), HapType::LockCurrentState => "1D".into(), HapType::LockLastKnownAction => "1C".into(), HapType::LockManagementAutoSecurityTimeout => "1A".into(), HapType::LockPhysicalControls => "A7".into(), HapType::LockTargetState => "1E".into(), HapType::Logs => "1F".into(), HapType::MacRetransmissionMaximum => "247".into(), HapType::MacTransmissionCounters => "248".into(), HapType::ManagedNetworkEnable => "215".into(), HapType::ManuallyDisabled => "227".into(), HapType::Manufacturer => "20".into(), HapType::MaximumTransmitPower => "243".into(), HapType::Model => "21".into(), HapType::MotionDetected => "22".into(), HapType::MultifunctionButton => "26B".into(), HapType::Mute => "11A".into(), HapType::NfcAccessControlPoint => "264".into(), HapType::NfcAccessSupportedConfiguration => "265".into(), HapType::Name => "23".into(), HapType::NetworkAccessViolationControl => "21F".into(), HapType::NetworkClientControl => "20C".into(), HapType::NetworkClientStatusControl => "20D".into(), HapType::NightVision => "11B".into(), HapType::NitrogenDioxideDensity => "C4".into(), HapType::ObstructionDetected => "24".into(), HapType::OccupancyDetected => "71".into(), HapType::OperatingStateResponse => "232".into(), HapType::OpticalZoom => "11C".into(), HapType::OutletInUse => "26".into(), HapType::OzoneDensity => "C3".into(), HapType::Pm10Density => "C7".into(), HapType::Pm2_5Density => "C6".into(), HapType::PairSetup => "4C".into(), HapType::PairVerify => "4E".into(), HapType::PairingFeatures => "4F".into(), HapType::PasswordSetting => "E4".into(), HapType::PeriodicSnapshotsActive => "225".into(), HapType::PictureMode => "E2".into(), HapType::Ping => "23C".into(), HapType::PositionState => "72".into(), HapType::PowerModeSelection => "DF".into(), HapType::PowerState => "25".into(), HapType::ProductData => "220".into(), HapType::ProgramMode => "D1".into(), HapType::ProgrammableSwitchEvent => "73".into(), HapType::ProgrammableSwitchOutputState => "74".into(), HapType::ReceivedSignalStrengthIndication => "23F".into(), HapType::ReceiverSensitivity => "244".into(), HapType::RelativeHumidityDehumidifierThreshold => "C9".into(), HapType::RelativeHumidityHumidifierThreshold => "CA".into(), HapType::RemainingDuration => "D4".into(), HapType::RemoteKey => "E1".into(), HapType::RotationDirection => "28".into(), HapType::RotationSpeed => "29".into(), HapType::RouterStatus => "20E".into(), HapType::Saturation => "2F".into(), HapType::SecuritySystemAlarmType => "8E".into(), HapType::SecuritySystemCurrentState => "66".into(), HapType::SecuritySystemTargetState => "67".into(), HapType::SelectedAudioStreamConfiguration => "128".into(), HapType::SelectedCameraRecordingConfiguration => "209".into(), HapType::SelectedDiagnosticsModes => "24D".into(), HapType::SelectedStreamConfiguration => "117".into(), HapType::SerialNumber => "30".into(), HapType::ServiceSignature => "A5".into(), HapType::SetDuration => "D3".into(), HapType::SetupDataStreamTransport => "131".into(), HapType::SetupEndpoint => "118".into(), HapType::SetupTransferTransport => "201".into(), HapType::SignalToNoiseRatio => "241".into(), HapType::SiriEnable => "255".into(), HapType::SiriEndpointSessionStatus => "254".into(), HapType::SiriEngineVersion => "25A".into(), HapType::SiriInputType => "132".into(), HapType::SiriLightOnUse => "258".into(), HapType::SiriListening => "256".into(), HapType::SiriTouchToUse => "257".into(), HapType::SlatType => "C0".into(), HapType::SleepDiscoveryMode => "E8".into(), HapType::SleepInterval => "23A".into(), HapType::SmokeDetected => "76".into(), HapType::SoftwareRevision => "54".into(), HapType::StagedFirmwareVersion => "249".into(), HapType::StatusActive => "75".into(), HapType::StatusFault => "77".into(), HapType::StatusJammed => "78".into(), HapType::StatusLowBattery => "79".into(), HapType::StatusTampered => "7A".into(), HapType::StreamingStatus => "120".into(), HapType::SulphurDioxideDensity => "C5".into(), HapType::SupportedAssetTypes => "268".into(), HapType::SupportedAudioRecordingConfiguration => "207".into(), HapType::SupportedAudioStreamConfiguration => "115".into(), HapType::SupportedCameraRecordingConfiguration => "205".into(), HapType::SupportedCharacteristicValueTransitionConfiguration => "144".into(), HapType::SupportedDataStreamTransportConfiguration => "130".into(), HapType::SupportedDiagnosticsModes => "24C".into(), HapType::SupportedDiagnosticsSnapshot => "238".into(), HapType::SupportedFirmwareUpdateConfiguration => "233".into(), HapType::SupportedRtpConfiguration => "116".into(), HapType::SupportedRouterConfiguration => "210".into(), HapType::SupportedTargetConfiguration => "123".into(), HapType::SupportedTransferTransportConfiguration => "202".into(), HapType::SupportedVideoRecordingConfiguration => "206".into(), HapType::SupportedVideoStreamConfiguration => "114".into(), HapType::SwingMode => "B6".into(), HapType::TargetAirPurifierState => "A8".into(), HapType::TargetDoorState => "32".into(), HapType::TargetFanState => "BF".into(), HapType::TargetHeaterCoolerState => "B2".into(), HapType::TargetHeatingCoolingState => "33".into(), HapType::TargetHorizontalTiltAngle => "7B".into(), HapType::TargetHumidifierDehumidifierState => "B4".into(), HapType::TargetListConfiguration => "124".into(), HapType::TargetMediaState => "137".into(), HapType::TargetPosition => "7C".into(), HapType::TargetRelativeHumidity => "34".into(), HapType::TargetTemperature => "35".into(), HapType::TargetTiltAngle => "C2".into(), HapType::TargetVerticalTiltAngle => "7D".into(), HapType::TargetVisibilityState => "134".into(), HapType::TemperatureDisplayUnits => "36".into(), HapType::ThirdPartyCameraActive => "21C".into(), HapType::ThreadControlPoint => "704".into(), HapType::ThreadNodeCapabilities => "702".into(), HapType::ThreadOpenthreadVersion => "706".into(), HapType::ThreadStatus => "703".into(), HapType::TransmitPower => "242".into(), HapType::ValveType => "D5".into(), HapType::Version => "37".into(), HapType::VideoAnalysisActive => "229".into(), HapType::VolatileOrganicCompoundDensity => "C8".into(), HapType::Volume => "119".into(), HapType::VolumeControlType => "E9".into(), HapType::VolumeSelector => "EA".into(), HapType::WanConfigurationList => "211".into(), HapType::WanStatusList => "212".into(), HapType::WakeConfiguration => "222".into(), HapType::WiFiCapabilities => "22C".into(), HapType::WiFiConfigurationControl => "22D".into(), HapType::WiFiSatelliteStatus => "21E".into(), HapType::RecordingAudioActive => "226".into(), HapType::AccessCode => "260".into(), HapType::AccessControl => "DA".into(), HapType::AccessoryInformation => "3E".into(), HapType::AccessoryMetrics => "270".into(), HapType::AccessoryRuntimeInformation => "239".into(), HapType::AirPurifier => "BB".into(), HapType::AirQualitySensor => "8D".into(), HapType::AssetUpdate => "267".into(), HapType::Assistant => "26A".into(), HapType::AudioStreamManagement => "127".into(), HapType::Battery => "96".into(), HapType::CameraOperatingMode => "21A".into(), HapType::CameraRecordingManagement => "204".into(), HapType::CameraStreamManagement => "110".into(), HapType::CarbonDioxideSensor => "97".into(), HapType::CarbonMonoxideSensor => "7F".into(), HapType::CloudRelay => "5A".into(), HapType::ContactSensor => "80".into(), HapType::DataStreamTransportManagement => "129".into(), HapType::Diagnostics => "237".into(), HapType::Door => "81".into(), HapType::Doorbell => "121".into(), HapType::Fan => "40".into(), HapType::FanV2 => "B7".into(), HapType::Faucet => "D7".into(), HapType::FilterMaintenance => "BA".into(), HapType::GarageDoorOpener => "41".into(), HapType::HeaterCooler => "BC".into(), HapType::HumidifierDehumidifier => "BD".into(), HapType::HumiditySensor => "82".into(), HapType::InputSource => "D9".into(), HapType::IrrigationSystem => "CF".into(), HapType::Label => "CC".into(), HapType::LeakSensor => "83".into(), HapType::LightSensor => "84".into(), HapType::Lightbulb => "43".into(), HapType::LockManagement => "44".into(), HapType::LockMechanism => "45".into(), HapType::Microphone => "112".into(), HapType::MotionSensor => "85".into(), HapType::NfcAccessService => "266".into(), HapType::OccupancySensor => "86".into(), HapType::Outlet => "47".into(), HapType::Pairing => "55".into(), HapType::PowerManagement => "221".into(), HapType::ProtocolInformation => "A2".into(), HapType::SecuritySystem => "7E".into(), HapType::Siri => "133".into(), HapType::SiriEndpoint => "253".into(), HapType::Slats => "B9".into(), HapType::SmartSpeaker => "228".into(), HapType::SmokeSensor => "87".into(), HapType::Speaker => "113".into(), HapType::StatefulProgrammableSwitch => "88".into(), HapType::StatelessProgrammableSwitch => "89".into(), HapType::Switch => "49".into(), HapType::TargetControl => "125".into(), HapType::TargetControlManagement => "122".into(), HapType::Television => "D8".into(), HapType::TemperatureSensor => "8A".into(), HapType::Thermostat => "4A".into(), HapType::ThreadTransport => "701".into(), HapType::TransferTransportManagement => "203".into(), HapType::Valve => "D0".into(), HapType::WiFiRouter => "20A".into(), HapType::WiFiSatellite => "20F".into(), HapType::WiFiTransport => "22A".into(), HapType::Window => "8B".into(), HapType::WindowCovering => "8C".into(), } } } impl FromStr for HapType { type Err = Error; fn from_str(s: &str) -> Result { if let Ok(uuid) = Uuid::parse_str(s) { return Ok(HapType::Custom(uuid)); } match s { "unknown" => Ok(HapType::Unknown), "262" => Ok(HapType::AccessCodeControlPoint), "261" => Ok(HapType::AccessCodeSupportedConfiguration), "E5" => Ok(HapType::AccessControlLevel), "A6" => Ok(HapType::AccessoryFlags), "57" => Ok(HapType::AccessoryIdentifier), "B0" => Ok(HapType::Active), "E7" => Ok(HapType::ActiveIdentifier), "23B" => Ok(HapType::ActivityInterval), "1" => Ok(HapType::AdministratorOnlyAccess), "64" => Ok(HapType::AirParticulateDensity), "65" => Ok(HapType::AirParticulateSize), "25B" => Ok(HapType::AirplayEnable), "A4" => Ok(HapType::ApplicationMatchingIdentifier), "269" => Ok(HapType::AssetUpdateReadiness), "5" => Ok(HapType::AudioFeedback), "68" => Ok(HapType::BatteryLevel), "8" => Ok(HapType::Brightness), "126" => Ok(HapType::ButtonEvent), "246" => Ok(HapType::CcaEnergyDetectThreshold), "245" => Ok(HapType::CcaSignalDetectThreshold), "21D" => Ok(HapType::CameraOperatingModeIndicator), "92" => Ok(HapType::CarbonDioxideDetected), "93" => Ok(HapType::CarbonDioxideLevel), "94" => Ok(HapType::CarbonDioxidePeakLevel), "69" => Ok(HapType::CarbonMonoxideDetected), "90" => Ok(HapType::CarbonMonoxideLevel), "91" => Ok(HapType::CarbonMonoxidePeakLevel), "24B" => Ok(HapType::CharacteristicValueActiveTransitionCount), "143" => Ok(HapType::CharacteristicValueTransitionControl), "8F" => Ok(HapType::ChargingState), "DD" => Ok(HapType::ClosedCaptions), "5E" => Ok(HapType::CloudRelayControlPoint), "5C" => Ok(HapType::CloudRelayCurrentState), "5B" => Ok(HapType::CloudRelayEnableStatus), "CE" => Ok(HapType::ColorTemperature), "263" => Ok(HapType::ConfigurationState), "E3" => Ok(HapType::ConfiguredName), "6A" => Ok(HapType::ContactSensorState), "D" => Ok(HapType::CoolingThresholdTemperature), "A9" => Ok(HapType::CurrentAirPurifierState), "95" => Ok(HapType::CurrentAirQuality), "E" => Ok(HapType::CurrentDoorState), "AF" => Ok(HapType::CurrentFanState), "B1" => Ok(HapType::CurrentHeaterCoolerState), "F" => Ok(HapType::CurrentHeatingCoolingState), "6C" => Ok(HapType::CurrentHorizontalTiltAngle), "B3" => Ok(HapType::CurrentHumidifierDehumidifierState), "6B" => Ok(HapType::CurrentLightLevel), "E0" => Ok(HapType::CurrentMediaState), "6D" => Ok(HapType::CurrentPosition), "10" => Ok(HapType::CurrentRelativeHumidity), "AA" => Ok(HapType::CurrentSlatState), "11" => Ok(HapType::CurrentTemperature), "C1" => Ok(HapType::CurrentTiltAngle), "22B" => Ok(HapType::CurrentTransport), "6E" => Ok(HapType::CurrentVerticalTiltAngle), "135" => Ok(HapType::CurrentVisibilityState), "B5" => Ok(HapType::CurrentWaterLevel), "138" => Ok(HapType::DataStreamHapTransport), "139" => Ok(HapType::DataStreamHapTransportInterrupt), "11D" => Ok(HapType::DigitalZoom), "136" => Ok(HapType::DisplayOrder), "23D" => Ok(HapType::EventRetransmissionMaximum), "223" => Ok(HapType::EventSnapshotsActive), "23E" => Ok(HapType::EventTransmissionCounters), "AC" => Ok(HapType::FilterChangeIndication), "AB" => Ok(HapType::FilterLifeLevel), "AD" => Ok(HapType::FilterResetChangeIndication), "52" => Ok(HapType::FirmwareRevision), "234" => Ok(HapType::FirmwareUpdateReadiness), "235" => Ok(HapType::FirmwareUpdateStatus), "26C" => Ok(HapType::HardwareFinish), "53" => Ok(HapType::HardwareRevision), "24A" => Ok(HapType::HeartBeat), "12" => Ok(HapType::HeatingThresholdTemperature), "6F" => Ok(HapType::HoldPosition), "21B" => Ok(HapType::HomekitCameraActive), "13" => Ok(HapType::Hue), "E6" => Ok(HapType::Identifier), "14" => Ok(HapType::Identify), "11F" => Ok(HapType::ImageMirroring), "11E" => Ok(HapType::ImageRotation), "D2" => Ok(HapType::InUse), "DC" => Ok(HapType::InputDeviceType), "DB" => Ok(HapType::InputSourceType), "D6" => Ok(HapType::IsConfigured), "CB" => Ok(HapType::LabelIndex), "CD" => Ok(HapType::LabelNamespace), "70" => Ok(HapType::LeakDetected), "50" => Ok(HapType::ListPairings), "19" => Ok(HapType::LockControlPoint), "1D" => Ok(HapType::LockCurrentState), "1C" => Ok(HapType::LockLastKnownAction), "1A" => Ok(HapType::LockManagementAutoSecurityTimeout), "A7" => Ok(HapType::LockPhysicalControls), "1E" => Ok(HapType::LockTargetState), "1F" => Ok(HapType::Logs), "247" => Ok(HapType::MacRetransmissionMaximum), "248" => Ok(HapType::MacTransmissionCounters), "215" => Ok(HapType::ManagedNetworkEnable), "227" => Ok(HapType::ManuallyDisabled), "20" => Ok(HapType::Manufacturer), "243" => Ok(HapType::MaximumTransmitPower), "21" => Ok(HapType::Model), "22" => Ok(HapType::MotionDetected), "26B" => Ok(HapType::MultifunctionButton), "11A" => Ok(HapType::Mute), "264" => Ok(HapType::NfcAccessControlPoint), "265" => Ok(HapType::NfcAccessSupportedConfiguration), "23" => Ok(HapType::Name), "21F" => Ok(HapType::NetworkAccessViolationControl), "20C" => Ok(HapType::NetworkClientControl), "20D" => Ok(HapType::NetworkClientStatusControl), "11B" => Ok(HapType::NightVision), "C4" => Ok(HapType::NitrogenDioxideDensity), "24" => Ok(HapType::ObstructionDetected), "71" => Ok(HapType::OccupancyDetected), "232" => Ok(HapType::OperatingStateResponse), "11C" => Ok(HapType::OpticalZoom), "26" => Ok(HapType::OutletInUse), "C3" => Ok(HapType::OzoneDensity), "C7" => Ok(HapType::Pm10Density), "C6" => Ok(HapType::Pm2_5Density), "4C" => Ok(HapType::PairSetup), "4E" => Ok(HapType::PairVerify), "4F" => Ok(HapType::PairingFeatures), "E4" => Ok(HapType::PasswordSetting), "225" => Ok(HapType::PeriodicSnapshotsActive), "E2" => Ok(HapType::PictureMode), "23C" => Ok(HapType::Ping), "72" => Ok(HapType::PositionState), "DF" => Ok(HapType::PowerModeSelection), "25" => Ok(HapType::PowerState), "220" => Ok(HapType::ProductData), "D1" => Ok(HapType::ProgramMode), "73" => Ok(HapType::ProgrammableSwitchEvent), "74" => Ok(HapType::ProgrammableSwitchOutputState), "23F" => Ok(HapType::ReceivedSignalStrengthIndication), "244" => Ok(HapType::ReceiverSensitivity), "C9" => Ok(HapType::RelativeHumidityDehumidifierThreshold), "CA" => Ok(HapType::RelativeHumidityHumidifierThreshold), "D4" => Ok(HapType::RemainingDuration), "E1" => Ok(HapType::RemoteKey), "28" => Ok(HapType::RotationDirection), "29" => Ok(HapType::RotationSpeed), "20E" => Ok(HapType::RouterStatus), "2F" => Ok(HapType::Saturation), "8E" => Ok(HapType::SecuritySystemAlarmType), "66" => Ok(HapType::SecuritySystemCurrentState), "67" => Ok(HapType::SecuritySystemTargetState), "128" => Ok(HapType::SelectedAudioStreamConfiguration), "209" => Ok(HapType::SelectedCameraRecordingConfiguration), "24D" => Ok(HapType::SelectedDiagnosticsModes), "117" => Ok(HapType::SelectedStreamConfiguration), "30" => Ok(HapType::SerialNumber), "A5" => Ok(HapType::ServiceSignature), "D3" => Ok(HapType::SetDuration), "131" => Ok(HapType::SetupDataStreamTransport), "118" => Ok(HapType::SetupEndpoint), "201" => Ok(HapType::SetupTransferTransport), "241" => Ok(HapType::SignalToNoiseRatio), "255" => Ok(HapType::SiriEnable), "254" => Ok(HapType::SiriEndpointSessionStatus), "25A" => Ok(HapType::SiriEngineVersion), "132" => Ok(HapType::SiriInputType), "258" => Ok(HapType::SiriLightOnUse), "256" => Ok(HapType::SiriListening), "257" => Ok(HapType::SiriTouchToUse), "C0" => Ok(HapType::SlatType), "E8" => Ok(HapType::SleepDiscoveryMode), "23A" => Ok(HapType::SleepInterval), "76" => Ok(HapType::SmokeDetected), "54" => Ok(HapType::SoftwareRevision), "249" => Ok(HapType::StagedFirmwareVersion), "75" => Ok(HapType::StatusActive), "77" => Ok(HapType::StatusFault), "78" => Ok(HapType::StatusJammed), "79" => Ok(HapType::StatusLowBattery), "7A" => Ok(HapType::StatusTampered), "120" => Ok(HapType::StreamingStatus), "C5" => Ok(HapType::SulphurDioxideDensity), "268" => Ok(HapType::SupportedAssetTypes), "207" => Ok(HapType::SupportedAudioRecordingConfiguration), "115" => Ok(HapType::SupportedAudioStreamConfiguration), "205" => Ok(HapType::SupportedCameraRecordingConfiguration), "144" => Ok(HapType::SupportedCharacteristicValueTransitionConfiguration), "130" => Ok(HapType::SupportedDataStreamTransportConfiguration), "24C" => Ok(HapType::SupportedDiagnosticsModes), "238" => Ok(HapType::SupportedDiagnosticsSnapshot), "233" => Ok(HapType::SupportedFirmwareUpdateConfiguration), "116" => Ok(HapType::SupportedRtpConfiguration), "210" => Ok(HapType::SupportedRouterConfiguration), "123" => Ok(HapType::SupportedTargetConfiguration), "202" => Ok(HapType::SupportedTransferTransportConfiguration), "206" => Ok(HapType::SupportedVideoRecordingConfiguration), "114" => Ok(HapType::SupportedVideoStreamConfiguration), "B6" => Ok(HapType::SwingMode), "A8" => Ok(HapType::TargetAirPurifierState), "32" => Ok(HapType::TargetDoorState), "BF" => Ok(HapType::TargetFanState), "B2" => Ok(HapType::TargetHeaterCoolerState), "33" => Ok(HapType::TargetHeatingCoolingState), "7B" => Ok(HapType::TargetHorizontalTiltAngle), "B4" => Ok(HapType::TargetHumidifierDehumidifierState), "124" => Ok(HapType::TargetListConfiguration), "137" => Ok(HapType::TargetMediaState), "7C" => Ok(HapType::TargetPosition), "34" => Ok(HapType::TargetRelativeHumidity), "35" => Ok(HapType::TargetTemperature), "C2" => Ok(HapType::TargetTiltAngle), "7D" => Ok(HapType::TargetVerticalTiltAngle), "134" => Ok(HapType::TargetVisibilityState), "36" => Ok(HapType::TemperatureDisplayUnits), "21C" => Ok(HapType::ThirdPartyCameraActive), "704" => Ok(HapType::ThreadControlPoint), "702" => Ok(HapType::ThreadNodeCapabilities), "706" => Ok(HapType::ThreadOpenthreadVersion), "703" => Ok(HapType::ThreadStatus), "242" => Ok(HapType::TransmitPower), "D5" => Ok(HapType::ValveType), "37" => Ok(HapType::Version), "229" => Ok(HapType::VideoAnalysisActive), "C8" => Ok(HapType::VolatileOrganicCompoundDensity), "119" => Ok(HapType::Volume), "E9" => Ok(HapType::VolumeControlType), "EA" => Ok(HapType::VolumeSelector), "211" => Ok(HapType::WanConfigurationList), "212" => Ok(HapType::WanStatusList), "222" => Ok(HapType::WakeConfiguration), "22C" => Ok(HapType::WiFiCapabilities), "22D" => Ok(HapType::WiFiConfigurationControl), "21E" => Ok(HapType::WiFiSatelliteStatus), "226" => Ok(HapType::RecordingAudioActive), "260" => Ok(HapType::AccessCode), "DA" => Ok(HapType::AccessControl), "3E" => Ok(HapType::AccessoryInformation), "270" => Ok(HapType::AccessoryMetrics), "239" => Ok(HapType::AccessoryRuntimeInformation), "BB" => Ok(HapType::AirPurifier), "8D" => Ok(HapType::AirQualitySensor), "267" => Ok(HapType::AssetUpdate), "26A" => Ok(HapType::Assistant), "127" => Ok(HapType::AudioStreamManagement), "96" => Ok(HapType::Battery), "21A" => Ok(HapType::CameraOperatingMode), "204" => Ok(HapType::CameraRecordingManagement), "110" => Ok(HapType::CameraStreamManagement), "97" => Ok(HapType::CarbonDioxideSensor), "7F" => Ok(HapType::CarbonMonoxideSensor), "5A" => Ok(HapType::CloudRelay), "80" => Ok(HapType::ContactSensor), "129" => Ok(HapType::DataStreamTransportManagement), "237" => Ok(HapType::Diagnostics), "81" => Ok(HapType::Door), "121" => Ok(HapType::Doorbell), "40" => Ok(HapType::Fan), "B7" => Ok(HapType::FanV2), "D7" => Ok(HapType::Faucet), "BA" => Ok(HapType::FilterMaintenance), "41" => Ok(HapType::GarageDoorOpener), "BC" => Ok(HapType::HeaterCooler), "BD" => Ok(HapType::HumidifierDehumidifier), "82" => Ok(HapType::HumiditySensor), "D9" => Ok(HapType::InputSource), "CF" => Ok(HapType::IrrigationSystem), "CC" => Ok(HapType::Label), "83" => Ok(HapType::LeakSensor), "84" => Ok(HapType::LightSensor), "43" => Ok(HapType::Lightbulb), "44" => Ok(HapType::LockManagement), "45" => Ok(HapType::LockMechanism), "112" => Ok(HapType::Microphone), "85" => Ok(HapType::MotionSensor), "266" => Ok(HapType::NfcAccessService), "86" => Ok(HapType::OccupancySensor), "47" => Ok(HapType::Outlet), "55" => Ok(HapType::Pairing), "221" => Ok(HapType::PowerManagement), "A2" => Ok(HapType::ProtocolInformation), "7E" => Ok(HapType::SecuritySystem), "133" => Ok(HapType::Siri), "253" => Ok(HapType::SiriEndpoint), "B9" => Ok(HapType::Slats), "228" => Ok(HapType::SmartSpeaker), "87" => Ok(HapType::SmokeSensor), "113" => Ok(HapType::Speaker), "88" => Ok(HapType::StatefulProgrammableSwitch), "89" => Ok(HapType::StatelessProgrammableSwitch), "49" => Ok(HapType::Switch), "125" => Ok(HapType::TargetControl), "122" => Ok(HapType::TargetControlManagement), "D8" => Ok(HapType::Television), "8A" => Ok(HapType::TemperatureSensor), "4A" => Ok(HapType::Thermostat), "701" => Ok(HapType::ThreadTransport), "203" => Ok(HapType::TransferTransportManagement), "D0" => Ok(HapType::Valve), "20A" => Ok(HapType::WiFiRouter), "20F" => Ok(HapType::WiFiSatellite), "22A" => Ok(HapType::WiFiTransport), "8B" => Ok(HapType::Window), "8C" => Ok(HapType::WindowCovering), _ => Err(Error::InvalidHapTypeString(s.to_string())), } } } impl Default for HapType { fn default() -> HapType { HapType::Unknown } } impl<'de> Deserialize<'de> for HapType { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de>, { let s = String::deserialize(deserializer)?; let hap_type = HapType::from_str(&s).map_err(de::Error::custom)?; Ok(hap_type) } } impl Serialize for HapType { fn serialize(&self, serializer: S) -> Result { serializer.serialize_str(&self.to_string()) } } ================================================ FILE: src/lib.rs ================================================ pub use ed25519_dalek::Keypair as Ed25519Keypair; pub use futures; pub use macaddr::MacAddr6 as MacAddress; pub use serde_json; pub use crate::{ config::Config, error::Error, hap_type::HapType, pin::Pin, transport::bonjour::{BonjourFeatureFlag, BonjourStatusFlag}, }; mod config; mod error; mod event; mod hap_type; mod pin; mod pointer; mod tlv; mod transport; /// Definitions of HomeKit accessories. pub mod accessory; /// Definitions of HomeKit characteristics. pub mod characteristic; /// Representation of paired controllers. pub mod pairing; /// The HomeKit Accessory Server implementation. pub mod server; /// Definitions of HomeKit services. pub mod service; /// Representations of persistent storage. pub mod storage; /// `Result` type redefinition. pub type Result = std::result::Result; ================================================ FILE: src/pairing.rs ================================================ use serde::{Deserialize, Serialize}; use uuid::Uuid; use crate::{Error, Result}; /// A [`Pairing`](Pairing) represents a paired controller. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct Pairing { pub id: Uuid, pub permissions: Permissions, pub public_key: [u8; 32], } impl Pairing { /// Creates a new [`Pairing`](Pairing). pub fn new(id: Uuid, permissions: Permissions, public_key: [u8; 32]) -> Pairing { Pairing { id, permissions, public_key, } } /// Deserializes a [`Pairing`](Pairing) from bytes. pub fn from_bytes(bytes: &[u8]) -> Result { let value = serde_json::from_slice(&bytes)?; Ok(value) } /// Serializes a [`Pairing`](Pairing) to bytes. pub fn as_bytes(&self) -> Result> { let value = serde_json::to_vec(&self)?; Ok(value) } } #[cfg(test)] mod tests { use super::*; #[test] fn test_pairing_from_bytes() { let pairing = Pairing { id: Uuid::parse_str("bc158b86-cabf-432d-aee4-422ef0e3f1d5").unwrap(), permissions: Permissions::Admin, public_key: [ 215, 90, 152, 1, 130, 177, 10, 183, 213, 75, 254, 211, 201, 100, 7, 58, 14, 225, 114, 243, 218, 166, 35, 37, 175, 2, 26, 104, 247, 7, 81, 26, ], }; assert_eq!( Pairing::from_bytes(&b"{\"id\":\"bc158b86-cabf-432d-aee4-422ef0e3f1d5\",\"permissions\":\"0x01\",\"public_key\":[215,90,152,1,130,177,10,183,213,75,254,211,201,100,7,58,14,225,114,243,218,166,35,37,175,2,26,104,247,7,81,26]}".to_vec()).unwrap(), pairing ); } #[test] fn test_pairing_to_bytes() { let pairing = Pairing { id: Uuid::parse_str("bc158b86-cabf-432d-aee4-422ef0e3f1d5").unwrap(), permissions: Permissions::User, public_key: [ 215, 90, 152, 1, 130, 177, 10, 183, 213, 75, 254, 211, 201, 100, 7, 58, 14, 225, 114, 243, 218, 166, 35, 37, 175, 2, 26, 104, 247, 7, 81, 26, ], }; assert_eq!( pairing.as_bytes().unwrap(), b"{\"id\":\"bc158b86-cabf-432d-aee4-422ef0e3f1d5\",\"permissions\":\"0x00\",\"public_key\":[215,90,152,1,130,177,10,183,213,75,254,211,201,100,7,58,14,225,114,243,218,166,35,37,175,2,26,104,247,7,81,26]}".to_vec() ); } } /// The permissions of a paired controller. #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub enum Permissions { #[serde(rename = "0x00")] User, /// Admins are pairings that have the admin bit set. Admins are exclusively authorized to add, remove, and list /// pairings. #[serde(rename = "0x01")] Admin, } impl Permissions { /// Converts a Byte value to the corresponding `Permissions` variant. pub fn from_byte(byte: u8) -> Result { match byte { 0x00 => Ok(Permissions::User), 0x01 => Ok(Permissions::Admin), _ => Err(Error::InvalidPairingPermission(byte)), } } /// Converts a `Permissions` variant to the corresponding Byte value. pub fn as_byte(&self) -> u8 { match *self { Permissions::User => 0x00, Permissions::Admin => 0x01, } } } ================================================ FILE: src/pin.rs ================================================ use serde::{Deserialize, Serialize}; use crate::{Error, Result}; const INVALID_PINS: [[u8; 8]; 12] = [ [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9, 9, 9], [1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], ]; /// The `Pin` struct represents the server's 8 digit pin used for pairing. /// /// The pin consists of eight digits between 0 and 9 and defaults to `11122333`. /// /// The following pins are considered too easy and are therefore not allowed: /// - `00000000` /// - `11111111` /// - `22222222` /// - `33333333` /// - `44444444` /// - `55555555` /// - `66666666` /// - `77777777` /// - `88888888` /// - `99999999` /// - `12345678` /// - `87654321` #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct Pin { pin: [u8; 8], } impl Pin { /// Creates a new `Pin`. pub fn new(pin: [u8; 8]) -> Result { if INVALID_PINS.contains(&pin) { return Err(Error::PinTooEasy); } for digit in &pin { if digit > &9 { return Err(Error::InvalidPin); } } Ok(Pin { pin }) } // TODO: fix UTF-8 encoding here // pub fn as_bytes(&self) -> [u8; 10] { // [ // self.pin[0], // self.pin[1], // self.pin[2], // 45, // '-' // self.pin[3], // self.pin[4], // 45, // '-' // self.pin[5], // self.pin[6], // self.pin[7], // ] // } } impl ToString for Pin { fn to_string(&self) -> String { format!( "{}{}{}-{}{}-{}{}{}", &self.pin[0], &self.pin[1], &self.pin[2], &self.pin[3], &self.pin[4], &self.pin[5], &self.pin[6], &self.pin[7], ) } } mod tests { #[allow(unused_imports)] use super::*; // #[test] // fn test_invalid_pin() { // let too_easy_pin = Pin::new([1, 2, 3, 4, 5, 6, 7, 8]); // let pin_with_invalid_number = Pin::new([0, 0, 0, 0, 0, 0, 0, 123]); // } #[test] fn test_to_string() { let pin = Pin::new([1, 1, 1, 2, 2, 3, 3, 3]).unwrap(); assert_eq!(pin.to_string(), "111-22-333".to_string()); } // #[test] // fn test_as_bytes() { // let pin = Pin::new([1, 1, 1, 2, 2, 3, 3, 3]).unwrap(); // let bytes = pin.as_bytes(); // assert_eq!(bytes, "111-22-333".to_string().as_bytes()); // } } ================================================ FILE: src/pointer.rs ================================================ use futures::lock::Mutex; use std::sync::{Arc, RwLock}; use uuid::Uuid; use crate::{accessory, event, storage}; pub type ControllerId = Arc>>; pub type EventEmitter = Arc>; pub type EventSubscriptions = Arc>>; pub type AccessoryDatabase = Arc>; pub type Accessory = Arc>>; pub type Storage = Arc>>; pub type Config = Arc>; pub type MdnsResponder = Arc>; ================================================ FILE: src/server/ip.rs ================================================ use async_trait::async_trait; use futures::{ future::{BoxFuture, FutureExt}, lock::Mutex, }; use log::{error, info}; use std::sync::Arc; use crate::{ accessory::HapAccessory, config::Config, event::{Event, EventEmitter}, pointer, server::Server, storage::{accessory_database::AccessoryDatabase, Storage}, transport::{http::server::Server as HttpServer, mdns::MdnsResponder}, BonjourStatusFlag, Result, }; /// HAP Server via TCP/IP. #[derive(Clone)] pub struct IpServer { config: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, http_server: HttpServer, mdns_responder: pointer::MdnsResponder, aid_cache: Arc>>, } impl IpServer { /// Creates a new [`IpServer`](IpServer). /// /// # Examples /// ```no_run /// use tokio; /// /// use hap::{ /// accessory::{lightbulb::LightbulbAccessory, AccessoryCategory, AccessoryInformation}, /// server::{IpServer, Server}, /// storage::{FileStorage, Storage}, /// Config, /// MacAddress, /// Pin, /// Result, /// }; /// /// #[tokio::main] /// async fn main() -> Result<()> { /// let lightbulb = LightbulbAccessory::new(1, AccessoryInformation { /// name: "Acme Lightbulb".into(), /// ..Default::default() /// })?; /// /// let mut storage = FileStorage::current_dir().await?; /// /// let config = match storage.load_config().await { /// Ok(mut config) => { /// config.redetermine_local_ip(); /// storage.save_config(&config).await?; /// config /// }, /// Err(_) => { /// let config = Config { /// pin: Pin::new([1, 1, 1, 2, 2, 3, 3, 3])?, /// name: "Acme Lightbulb".into(), /// device_id: MacAddress::from([10, 20, 30, 40, 50, 60]), /// category: AccessoryCategory::Lightbulb, /// ..Default::default() /// }; /// storage.save_config(&config).await?; /// config /// }, /// }; /// /// let mut server = IpServer::new(config, storage).await?; /// server.add_accessory(lightbulb).await?; /// /// let handle = server.run_handle(); /// /// std::env::set_var("RUST_LOG", "hap=info"); /// env_logger::init(); /// /// handle.await /// } /// ``` pub async fn new(config: Config, storage: S) -> Result { let config = Arc::new(Mutex::new(config)); let storage: pointer::Storage = Arc::new(Mutex::new(Box::new(storage))); let config_ = config.clone(); let storage_ = storage.clone(); let mut event_emitter = EventEmitter::new(); let mut s = storage_.lock().await; if s.count_pairings().await? > 0 { info!("1 or more controllers paired; setting Bonjour status flag to `Zero`"); let mut c = config_.lock().await; c.status_flag = BonjourStatusFlag::Zero; s.save_config(&c).await?; } else { info!("0 controllers paired; setting Bonjour status flag to `Not Paired`"); let mut c = config_.lock().await; c.status_flag = BonjourStatusFlag::NotPaired; s.save_config(&c).await?; } drop(s); let mdns_responder = Arc::new(Mutex::new(MdnsResponder::new(config.clone()).await)); let mdns_responder_ = mdns_responder.clone(); event_emitter.add_listener(Box::new(move |event| { let config_ = config_.clone(); let storage_ = storage_.clone(); let mdns_responder_ = mdns_responder_.clone(); async move { match *event { Event::ControllerPaired { id } => { info!("controller {} paired", id); let pairing_count = storage_.lock().await.count_pairings().await; if let Ok(count) = pairing_count { if count > 0 { info!("1 or more controllers paired; setting Bonjour status flag to `Zero`"); let mut c = config_.lock().await; c.status_flag = BonjourStatusFlag::Zero; storage_ .lock() .await .save_config(&c) .await .map_err(|e| error!("error saving the config: {:?}", e)) .ok(); drop(c); mdns_responder_.lock().await.update_records().await; } } }, Event::ControllerUnpaired { id } => { info!("controller {} unpaired", id); let pairing_count = storage_.lock().await.count_pairings().await; // TODO - `pairing_count` is an Err if let Ok(count) = pairing_count { if count == 0 { info!("0 controllers paired; setting Bonjour status flag to `Not Paired`"); let mut c = config_.lock().await; c.status_flag = BonjourStatusFlag::NotPaired; storage_ .lock() .await .save_config(&c) .await .map_err(|e| error!("error saving the config: {:?}", e)) .ok(); drop(c); mdns_responder_.lock().await.update_records().await; } } }, _ => {}, } } .boxed() })); let event_emitter = Arc::new(Mutex::new(event_emitter)); let accessory_database = Arc::new(Mutex::new(AccessoryDatabase::new(event_emitter.clone()))); let http_server = HttpServer::new( config.clone(), storage.clone(), accessory_database.clone(), event_emitter, mdns_responder.clone(), ); let mut storage_lock = storage.lock().await; let aid_cache = Arc::new(Mutex::new(match storage_lock.load_aid_cache().await { Ok(aid_cache) => aid_cache, Err(_) => { storage_lock.delete_aid_cache().await.ok(); let aid_cache = Vec::new(); storage_lock.save_aid_cache(&aid_cache).await?; aid_cache }, })); drop(storage_lock); let server = IpServer { config, storage, accessory_database, http_server, mdns_responder, aid_cache, }; Ok(server) } } #[async_trait] impl Server for IpServer { fn run_handle(&self) -> BoxFuture> { let http_handle = self.http_server.run_handle(); let mdns_responder = self.mdns_responder.clone(); let handle = async move { let mdns_handle = mdns_responder.lock().await.run_handle(); futures::try_join!(http_handle, mdns_handle.map(|_| Ok(())))?; Ok(()) } .boxed(); Box::pin(handle) } fn config_pointer(&self) -> pointer::Config { self.config.clone() } fn storage_pointer(&self) -> pointer::Storage { self.storage.clone() } async fn add_accessory(&self, accessory: A) -> Result { let aid = accessory.get_id(); let accessory = self .accessory_database .lock() .await .add_accessory(Box::new(accessory))?; let mut aid_cache = self.aid_cache.lock().await; if !aid_cache.contains(&aid) { aid_cache.push(aid); self.storage.lock().await.save_aid_cache(&aid_cache).await?; let mut config = self.config.lock().await; config.configuration_number += 1; self.storage.lock().await.save_config(&config).await?; } Ok(accessory) } async fn remove_accessory(&self, accessory: &pointer::Accessory) -> Result<()> { let aid = accessory.lock().await.get_id(); self.accessory_database .lock() .await .remove_accessory(&accessory) .await?; let mut aid_cache = self.aid_cache.lock().await; if aid_cache.contains(&aid) { aid_cache.retain(|id| *id != aid); self.storage.lock().await.save_aid_cache(&aid_cache).await?; let mut config = self.config.lock().await; config.configuration_number += 1; } Ok(()) } // async fn factory_reset(&mut self) -> Result<()> { // unimplemented!(); // Ok(()) // } } ================================================ FILE: src/server/mod.rs ================================================ use async_trait::async_trait; use futures::future::BoxFuture; use crate::{accessory::HapAccessory, pointer, Result}; pub use ip::IpServer; mod ip; /// [`Server`](Server) is implemented by the transport methods this crate supports. Currently, that's just /// [`IpServer`](IpServer). #[async_trait] pub trait Server { /// Returns a [`BoxFuture`](BoxFuture) run handle to the server that can be passed to an executor. fn run_handle(&self) -> BoxFuture>; /// Returns a pointer to the [`Config`](crate::Config) of the server. fn config_pointer(&self) -> pointer::Config; /// Returns a pointer to the [`Storage`](crate::storage::Storage) of the server. fn storage_pointer(&self) -> pointer::Storage; /// Adds an accessory to the server and returns a pointer to it. async fn add_accessory(&self, accessory: A) -> Result; /// Takes a pointer to an accessory and removes it from the server. async fn remove_accessory(&self, accessory: &pointer::Accessory) -> Result<()>; // /// Every accessory must support a manufacturer-defined mechanism to restore itself to a “factory reset” state // where /// all pairing information is erased and restored to factory default settings. This method is doing // just that. async fn factory_reset(&mut self) -> Result<()>; } ================================================ FILE: src/service/generated/access_code.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, access_code_control_point::AccessCodeControlPointCharacteristic, access_code_supported_configuration::AccessCodeSupportedConfigurationCharacteristic, configuration_state::ConfigurationStateCharacteristic, }, HapType, }; /// Access Code service. #[derive(Debug, Default)] pub struct AccessCodeService { /// Instance ID of the Access Code service. id: u64, /// [`HapType`](HapType) of the Access Code service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Access Code Control Point characteristic (required). pub access_code_control_point: AccessCodeControlPointCharacteristic, /// Access Code Supported Configuration characteristic (required). pub access_code_supported_configuration: AccessCodeSupportedConfigurationCharacteristic, /// Configuration State characteristic (required). pub configuration_state: ConfigurationStateCharacteristic, } impl AccessCodeService { /// Creates a new Access Code service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AccessCode, access_code_control_point: AccessCodeControlPointCharacteristic::new(id + 1 + 0, accessory_id), access_code_supported_configuration: AccessCodeSupportedConfigurationCharacteristic::new(id + 1 + 1, accessory_id), configuration_state: ConfigurationStateCharacteristic::new(id + 1 + 2, accessory_id), ..Default::default() } } } impl HapService for AccessCodeService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.access_code_control_point, &self.access_code_supported_configuration, &self.configuration_state, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.access_code_control_point, &mut self.access_code_supported_configuration, &mut self.configuration_state, ]; characteristics } } impl Serialize for AccessCodeService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/access_control.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, access_control_level::AccessControlLevelCharacteristic, password_setting::PasswordSettingCharacteristic, }, HapType, }; /// Access Control service. #[derive(Debug, Default)] pub struct AccessControlService { /// Instance ID of the Access Control service. id: u64, /// [`HapType`](HapType) of the Access Control service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Access Control Level characteristic (required). pub access_control_level: AccessControlLevelCharacteristic, /// Password Setting characteristic (optional). pub password_setting: Option, } impl AccessControlService { /// Creates a new Access Control service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AccessControl, access_control_level: AccessControlLevelCharacteristic::new(id + 1 + 0, accessory_id), password_setting: Some(PasswordSettingCharacteristic::new(id + 1 + 0 + 1, accessory_id)), ..Default::default() } } } impl HapService for AccessControlService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.access_control_level, ]; if let Some(c) = &self.password_setting { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.access_control_level, ]; if let Some(c) = &mut self.password_setting { characteristics.push(c); } characteristics } } impl Serialize for AccessControlService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/accessory_information.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, identify::IdentifyCharacteristic, manufacturer::ManufacturerCharacteristic, model::ModelCharacteristic, name::NameCharacteristic, serial_number::SerialNumberCharacteristic, accessory_flags::AccessoryFlagsCharacteristic, application_matching_identifier::ApplicationMatchingIdentifierCharacteristic, configured_name::ConfiguredNameCharacteristic, firmware_revision::FirmwareRevisionCharacteristic, hardware_finish::HardwareFinishCharacteristic, hardware_revision::HardwareRevisionCharacteristic, product_data::ProductDataCharacteristic, software_revision::SoftwareRevisionCharacteristic, }, HapType, }; /// Accessory Information service. #[derive(Debug, Default)] pub struct AccessoryInformationService { /// Instance ID of the Accessory Information service. id: u64, /// [`HapType`](HapType) of the Accessory Information service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Identify characteristic (required). pub identify: IdentifyCharacteristic, /// Manufacturer characteristic (required). pub manufacturer: ManufacturerCharacteristic, /// Model characteristic (required). pub model: ModelCharacteristic, /// Name characteristic (required). pub name: NameCharacteristic, /// Serial Number characteristic (required). pub serial_number: SerialNumberCharacteristic, /// Accessory Flags characteristic (optional). pub accessory_flags: Option, /// Application Matching Identifier characteristic (optional). pub application_matching_identifier: Option, /// Configured Name characteristic (optional). pub configured_name: Option, /// Firmware Revision characteristic (optional). pub firmware_revision: Option, /// Hardware Finish characteristic (optional). pub hardware_finish: Option, /// Hardware Revision characteristic (optional). pub hardware_revision: Option, /// Product Data characteristic (optional). pub product_data: Option, /// Software Revision characteristic (optional). pub software_revision: Option, } impl AccessoryInformationService { /// Creates a new Accessory Information service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AccessoryInformation, identify: IdentifyCharacteristic::new(id + 1 + 0, accessory_id), manufacturer: ManufacturerCharacteristic::new(id + 1 + 1, accessory_id), model: ModelCharacteristic::new(id + 1 + 2, accessory_id), name: NameCharacteristic::new(id + 1 + 3, accessory_id), serial_number: SerialNumberCharacteristic::new(id + 1 + 4, accessory_id), accessory_flags: Some(AccessoryFlagsCharacteristic::new(id + 1 + 0 + 5, accessory_id)), application_matching_identifier: Some(ApplicationMatchingIdentifierCharacteristic::new(id + 1 + 1 + 5, accessory_id)), configured_name: Some(ConfiguredNameCharacteristic::new(id + 1 + 2 + 5, accessory_id)), firmware_revision: Some(FirmwareRevisionCharacteristic::new(id + 1 + 3 + 5, accessory_id)), hardware_finish: Some(HardwareFinishCharacteristic::new(id + 1 + 4 + 5, accessory_id)), hardware_revision: Some(HardwareRevisionCharacteristic::new(id + 1 + 5 + 5, accessory_id)), product_data: Some(ProductDataCharacteristic::new(id + 1 + 6 + 5, accessory_id)), software_revision: Some(SoftwareRevisionCharacteristic::new(id + 1 + 7 + 5, accessory_id)), ..Default::default() } } } impl HapService for AccessoryInformationService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.identify, &self.manufacturer, &self.model, &self.name, &self.serial_number, ]; if let Some(c) = &self.accessory_flags { characteristics.push(c); } if let Some(c) = &self.application_matching_identifier { characteristics.push(c); } if let Some(c) = &self.configured_name { characteristics.push(c); } if let Some(c) = &self.firmware_revision { characteristics.push(c); } if let Some(c) = &self.hardware_finish { characteristics.push(c); } if let Some(c) = &self.hardware_revision { characteristics.push(c); } if let Some(c) = &self.product_data { characteristics.push(c); } if let Some(c) = &self.software_revision { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.identify, &mut self.manufacturer, &mut self.model, &mut self.name, &mut self.serial_number, ]; if let Some(c) = &mut self.accessory_flags { characteristics.push(c); } if let Some(c) = &mut self.application_matching_identifier { characteristics.push(c); } if let Some(c) = &mut self.configured_name { characteristics.push(c); } if let Some(c) = &mut self.firmware_revision { characteristics.push(c); } if let Some(c) = &mut self.hardware_finish { characteristics.push(c); } if let Some(c) = &mut self.hardware_revision { characteristics.push(c); } if let Some(c) = &mut self.product_data { characteristics.push(c); } if let Some(c) = &mut self.software_revision { characteristics.push(c); } characteristics } } impl Serialize for AccessoryInformationService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/accessory_metrics.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, }, HapType, }; /// Accessory Metrics service. #[derive(Debug, Default)] pub struct AccessoryMetricsService { /// Instance ID of the Accessory Metrics service. id: u64, /// [`HapType`](HapType) of the Accessory Metrics service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, } impl AccessoryMetricsService { /// Creates a new Accessory Metrics service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AccessoryMetrics, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), ..Default::default() } } } impl HapService for AccessoryMetricsService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, ]; characteristics } } impl Serialize for AccessoryMetricsService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/accessory_runtime_information.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, ping::PingCharacteristic, activity_interval::ActivityIntervalCharacteristic, heart_beat::HeartBeatCharacteristic, sleep_interval::SleepIntervalCharacteristic, }, HapType, }; /// Accessory Runtime Information service. #[derive(Debug, Default)] pub struct AccessoryRuntimeInformationService { /// Instance ID of the Accessory Runtime Information service. id: u64, /// [`HapType`](HapType) of the Accessory Runtime Information service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Ping characteristic (required). pub ping: PingCharacteristic, /// Activity Interval characteristic (optional). pub activity_interval: Option, /// Heart Beat characteristic (optional). pub heart_beat: Option, /// Sleep Interval characteristic (optional). pub sleep_interval: Option, } impl AccessoryRuntimeInformationService { /// Creates a new Accessory Runtime Information service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AccessoryRuntimeInformation, ping: PingCharacteristic::new(id + 1 + 0, accessory_id), activity_interval: Some(ActivityIntervalCharacteristic::new(id + 1 + 0 + 1, accessory_id)), heart_beat: Some(HeartBeatCharacteristic::new(id + 1 + 1 + 1, accessory_id)), sleep_interval: Some(SleepIntervalCharacteristic::new(id + 1 + 2 + 1, accessory_id)), ..Default::default() } } } impl HapService for AccessoryRuntimeInformationService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.ping, ]; if let Some(c) = &self.activity_interval { characteristics.push(c); } if let Some(c) = &self.heart_beat { characteristics.push(c); } if let Some(c) = &self.sleep_interval { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.ping, ]; if let Some(c) = &mut self.activity_interval { characteristics.push(c); } if let Some(c) = &mut self.heart_beat { characteristics.push(c); } if let Some(c) = &mut self.sleep_interval { characteristics.push(c); } characteristics } } impl Serialize for AccessoryRuntimeInformationService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/air_purifier.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, current_air_purifier_state::CurrentAirPurifierStateCharacteristic, target_air_purifier_state::TargetAirPurifierStateCharacteristic, lock_physical_controls::LockPhysicalControlsCharacteristic, name::NameCharacteristic, rotation_speed::RotationSpeedCharacteristic, swing_mode::SwingModeCharacteristic, }, HapType, }; /// Air Purifier service. #[derive(Debug, Default)] pub struct AirPurifierService { /// Instance ID of the Air Purifier service. id: u64, /// [`HapType`](HapType) of the Air Purifier service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Current Air Purifier State characteristic (required). pub current_air_purifier_state: CurrentAirPurifierStateCharacteristic, /// Target Air Purifier State characteristic (required). pub target_air_purifier_state: TargetAirPurifierStateCharacteristic, /// Lock Physical Controls characteristic (optional). pub lock_physical_controls: Option, /// Name characteristic (optional). pub name: Option, /// Rotation Speed characteristic (optional). pub rotation_speed: Option, /// Swing Mode characteristic (optional). pub swing_mode: Option, } impl AirPurifierService { /// Creates a new Air Purifier service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AirPurifier, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), current_air_purifier_state: CurrentAirPurifierStateCharacteristic::new(id + 1 + 1, accessory_id), target_air_purifier_state: TargetAirPurifierStateCharacteristic::new(id + 1 + 2, accessory_id), lock_physical_controls: Some(LockPhysicalControlsCharacteristic::new(id + 1 + 0 + 3, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 1 + 3, accessory_id)), rotation_speed: Some(RotationSpeedCharacteristic::new(id + 1 + 2 + 3, accessory_id)), swing_mode: Some(SwingModeCharacteristic::new(id + 1 + 3 + 3, accessory_id)), ..Default::default() } } } impl HapService for AirPurifierService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.current_air_purifier_state, &self.target_air_purifier_state, ]; if let Some(c) = &self.lock_physical_controls { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.rotation_speed { characteristics.push(c); } if let Some(c) = &self.swing_mode { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.current_air_purifier_state, &mut self.target_air_purifier_state, ]; if let Some(c) = &mut self.lock_physical_controls { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.rotation_speed { characteristics.push(c); } if let Some(c) = &mut self.swing_mode { characteristics.push(c); } characteristics } } impl Serialize for AirPurifierService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/air_quality_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_air_quality::CurrentAirQualityCharacteristic, nitrogen_dioxide_density::NitrogenDioxideDensityCharacteristic, ozone_density::OzoneDensityCharacteristic, pm10_density::Pm10DensityCharacteristic, pm2_5_density::Pm2_5DensityCharacteristic, sulphur_dioxide_density::SulphurDioxideDensityCharacteristic, volatile_organic_compound_density::VolatileOrganicCompoundDensityCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Air Quality Sensor service. #[derive(Debug, Default)] pub struct AirQualitySensorService { /// Instance ID of the Air Quality Sensor service. id: u64, /// [`HapType`](HapType) of the Air Quality Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Air Quality characteristic (required). pub current_air_quality: CurrentAirQualityCharacteristic, /// Nitrogen dioxide Density characteristic (optional). pub nitrogen_dioxide_density: Option, /// Ozone Density characteristic (optional). pub ozone_density: Option, /// PM10 Density characteristic (optional). pub pm10_density: Option, /// PM2.5 Density characteristic (optional). pub pm2_5_density: Option, /// Sulphur dioxide Density characteristic (optional). pub sulphur_dioxide_density: Option, /// Volatile Organic Compound Density characteristic (optional). pub volatile_organic_compound_density: Option, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl AirQualitySensorService { /// Creates a new Air Quality Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AirQualitySensor, current_air_quality: CurrentAirQualityCharacteristic::new(id + 1 + 0, accessory_id), nitrogen_dioxide_density: Some(NitrogenDioxideDensityCharacteristic::new(id + 1 + 0 + 1, accessory_id)), ozone_density: Some(OzoneDensityCharacteristic::new(id + 1 + 1 + 1, accessory_id)), pm10_density: Some(Pm10DensityCharacteristic::new(id + 1 + 2 + 1, accessory_id)), pm2_5_density: Some(Pm2_5DensityCharacteristic::new(id + 1 + 3 + 1, accessory_id)), sulphur_dioxide_density: Some(SulphurDioxideDensityCharacteristic::new(id + 1 + 4 + 1, accessory_id)), volatile_organic_compound_density: Some(VolatileOrganicCompoundDensityCharacteristic::new(id + 1 + 5 + 1, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 6 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 7 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 8 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 9 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 10 + 1, accessory_id)), ..Default::default() } } } impl HapService for AirQualitySensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_air_quality, ]; if let Some(c) = &self.nitrogen_dioxide_density { characteristics.push(c); } if let Some(c) = &self.ozone_density { characteristics.push(c); } if let Some(c) = &self.pm10_density { characteristics.push(c); } if let Some(c) = &self.pm2_5_density { characteristics.push(c); } if let Some(c) = &self.sulphur_dioxide_density { characteristics.push(c); } if let Some(c) = &self.volatile_organic_compound_density { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_air_quality, ]; if let Some(c) = &mut self.nitrogen_dioxide_density { characteristics.push(c); } if let Some(c) = &mut self.ozone_density { characteristics.push(c); } if let Some(c) = &mut self.pm10_density { characteristics.push(c); } if let Some(c) = &mut self.pm2_5_density { characteristics.push(c); } if let Some(c) = &mut self.sulphur_dioxide_density { characteristics.push(c); } if let Some(c) = &mut self.volatile_organic_compound_density { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for AirQualitySensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/asset_update.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, asset_update_readiness::AssetUpdateReadinessCharacteristic, supported_asset_types::SupportedAssetTypesCharacteristic, }, HapType, }; /// Asset Update service. #[derive(Debug, Default)] pub struct AssetUpdateService { /// Instance ID of the Asset Update service. id: u64, /// [`HapType`](HapType) of the Asset Update service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Asset Update Readiness characteristic (required). pub asset_update_readiness: AssetUpdateReadinessCharacteristic, /// Supported Asset Types characteristic (required). pub supported_asset_types: SupportedAssetTypesCharacteristic, } impl AssetUpdateService { /// Creates a new Asset Update service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AssetUpdate, asset_update_readiness: AssetUpdateReadinessCharacteristic::new(id + 1 + 0, accessory_id), supported_asset_types: SupportedAssetTypesCharacteristic::new(id + 1 + 1, accessory_id), ..Default::default() } } } impl HapService for AssetUpdateService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.asset_update_readiness, &self.supported_asset_types, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.asset_update_readiness, &mut self.supported_asset_types, ]; characteristics } } impl Serialize for AssetUpdateService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/assistant.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, identifier::IdentifierCharacteristic, name::NameCharacteristic, }, HapType, }; /// Assistant service. #[derive(Debug, Default)] pub struct AssistantService { /// Instance ID of the Assistant service. id: u64, /// [`HapType`](HapType) of the Assistant service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Identifier characteristic (required). pub identifier: IdentifierCharacteristic, /// Name characteristic (required). pub name: NameCharacteristic, } impl AssistantService { /// Creates a new Assistant service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Assistant, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), identifier: IdentifierCharacteristic::new(id + 1 + 1, accessory_id), name: NameCharacteristic::new(id + 1 + 2, accessory_id), ..Default::default() } } } impl HapService for AssistantService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.identifier, &self.name, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.identifier, &mut self.name, ]; characteristics } } impl Serialize for AssistantService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/audio_stream_management.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, supported_audio_stream_configuration::SupportedAudioStreamConfigurationCharacteristic, selected_audio_stream_configuration::SelectedAudioStreamConfigurationCharacteristic, }, HapType, }; /// Audio Stream Management service. #[derive(Debug, Default)] pub struct AudioStreamManagementService { /// Instance ID of the Audio Stream Management service. id: u64, /// [`HapType`](HapType) of the Audio Stream Management service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Supported Audio Stream Configuration characteristic (required). pub supported_audio_stream_configuration: SupportedAudioStreamConfigurationCharacteristic, /// Selected Audio Stream Configuration characteristic (required). pub selected_audio_stream_configuration: SelectedAudioStreamConfigurationCharacteristic, } impl AudioStreamManagementService { /// Creates a new Audio Stream Management service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::AudioStreamManagement, supported_audio_stream_configuration: SupportedAudioStreamConfigurationCharacteristic::new(id + 1 + 0, accessory_id), selected_audio_stream_configuration: SelectedAudioStreamConfigurationCharacteristic::new(id + 1 + 1, accessory_id), ..Default::default() } } } impl HapService for AudioStreamManagementService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.supported_audio_stream_configuration, &self.selected_audio_stream_configuration, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.supported_audio_stream_configuration, &mut self.selected_audio_stream_configuration, ]; characteristics } } impl Serialize for AudioStreamManagementService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/battery.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, battery_level::BatteryLevelCharacteristic, charging_state::ChargingStateCharacteristic, name::NameCharacteristic, }, HapType, }; /// Battery service. #[derive(Debug, Default)] pub struct BatteryService { /// Instance ID of the Battery service. id: u64, /// [`HapType`](HapType) of the Battery service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Status Low Battery characteristic (required). pub status_low_battery: StatusLowBatteryCharacteristic, /// Battery Level characteristic (optional). pub battery_level: Option, /// Charging State characteristic (optional). pub charging_state: Option, /// Name characteristic (optional). pub name: Option, } impl BatteryService { /// Creates a new Battery service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Battery, status_low_battery: StatusLowBatteryCharacteristic::new(id + 1 + 0, accessory_id), battery_level: Some(BatteryLevelCharacteristic::new(id + 1 + 0 + 1, accessory_id)), charging_state: Some(ChargingStateCharacteristic::new(id + 1 + 1 + 1, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 2 + 1, accessory_id)), ..Default::default() } } } impl HapService for BatteryService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.status_low_battery, ]; if let Some(c) = &self.battery_level { characteristics.push(c); } if let Some(c) = &self.charging_state { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.status_low_battery, ]; if let Some(c) = &mut self.battery_level { characteristics.push(c); } if let Some(c) = &mut self.charging_state { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } characteristics } } impl Serialize for BatteryService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/camera_operating_mode.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, event_snapshots_active::EventSnapshotsActiveCharacteristic, homekit_camera_active::HomekitCameraActiveCharacteristic, camera_operating_mode_indicator::CameraOperatingModeIndicatorCharacteristic, manually_disabled::ManuallyDisabledCharacteristic, night_vision::NightVisionCharacteristic, periodic_snapshots_active::PeriodicSnapshotsActiveCharacteristic, third_party_camera_active::ThirdPartyCameraActiveCharacteristic, }, HapType, }; /// Camera Operating Mode service. #[derive(Debug, Default)] pub struct CameraOperatingModeService { /// Instance ID of the Camera Operating Mode service. id: u64, /// [`HapType`](HapType) of the Camera Operating Mode service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Event Snapshots Active characteristic (required). pub event_snapshots_active: EventSnapshotsActiveCharacteristic, /// HomeKit Camera Active characteristic (required). pub homekit_camera_active: HomekitCameraActiveCharacteristic, /// Camera Operating Mode Indicator characteristic (optional). pub camera_operating_mode_indicator: Option, /// Manually disabled characteristic (optional). pub manually_disabled: Option, /// Night Vision characteristic (optional). pub night_vision: Option, /// Periodic Snapshots Active characteristic (optional). pub periodic_snapshots_active: Option, /// Third Party Camera Active characteristic (optional). pub third_party_camera_active: Option, } impl CameraOperatingModeService { /// Creates a new Camera Operating Mode service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::CameraOperatingMode, event_snapshots_active: EventSnapshotsActiveCharacteristic::new(id + 1 + 0, accessory_id), homekit_camera_active: HomekitCameraActiveCharacteristic::new(id + 1 + 1, accessory_id), camera_operating_mode_indicator: Some(CameraOperatingModeIndicatorCharacteristic::new(id + 1 + 0 + 2, accessory_id)), manually_disabled: Some(ManuallyDisabledCharacteristic::new(id + 1 + 1 + 2, accessory_id)), night_vision: Some(NightVisionCharacteristic::new(id + 1 + 2 + 2, accessory_id)), periodic_snapshots_active: Some(PeriodicSnapshotsActiveCharacteristic::new(id + 1 + 3 + 2, accessory_id)), third_party_camera_active: Some(ThirdPartyCameraActiveCharacteristic::new(id + 1 + 4 + 2, accessory_id)), ..Default::default() } } } impl HapService for CameraOperatingModeService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.event_snapshots_active, &self.homekit_camera_active, ]; if let Some(c) = &self.camera_operating_mode_indicator { characteristics.push(c); } if let Some(c) = &self.manually_disabled { characteristics.push(c); } if let Some(c) = &self.night_vision { characteristics.push(c); } if let Some(c) = &self.periodic_snapshots_active { characteristics.push(c); } if let Some(c) = &self.third_party_camera_active { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.event_snapshots_active, &mut self.homekit_camera_active, ]; if let Some(c) = &mut self.camera_operating_mode_indicator { characteristics.push(c); } if let Some(c) = &mut self.manually_disabled { characteristics.push(c); } if let Some(c) = &mut self.night_vision { characteristics.push(c); } if let Some(c) = &mut self.periodic_snapshots_active { characteristics.push(c); } if let Some(c) = &mut self.third_party_camera_active { characteristics.push(c); } characteristics } } impl Serialize for CameraOperatingModeService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/camera_recording_management.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, supported_camera_recording_configuration::SupportedCameraRecordingConfigurationCharacteristic, supported_video_recording_configuration::SupportedVideoRecordingConfigurationCharacteristic, supported_audio_recording_configuration::SupportedAudioRecordingConfigurationCharacteristic, selected_camera_recording_configuration::SelectedCameraRecordingConfigurationCharacteristic, recording_audio_active::RecordingAudioActiveCharacteristic, }, HapType, }; /// Camera Recording Management service. #[derive(Debug, Default)] pub struct CameraRecordingManagementService { /// Instance ID of the Camera Recording Management service. id: u64, /// [`HapType`](HapType) of the Camera Recording Management service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Supported Camera Recording Configuration characteristic (required). pub supported_camera_recording_configuration: SupportedCameraRecordingConfigurationCharacteristic, /// Supported Video Recording Configuration characteristic (required). pub supported_video_recording_configuration: SupportedVideoRecordingConfigurationCharacteristic, /// Supported Audio Recording Configuration characteristic (required). pub supported_audio_recording_configuration: SupportedAudioRecordingConfigurationCharacteristic, /// Selected Camera Recording Configuration characteristic (required). pub selected_camera_recording_configuration: SelectedCameraRecordingConfigurationCharacteristic, /// recording audio active characteristic (optional). pub recording_audio_active: Option, } impl CameraRecordingManagementService { /// Creates a new Camera Recording Management service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::CameraRecordingManagement, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), supported_camera_recording_configuration: SupportedCameraRecordingConfigurationCharacteristic::new(id + 1 + 1, accessory_id), supported_video_recording_configuration: SupportedVideoRecordingConfigurationCharacteristic::new(id + 1 + 2, accessory_id), supported_audio_recording_configuration: SupportedAudioRecordingConfigurationCharacteristic::new(id + 1 + 3, accessory_id), selected_camera_recording_configuration: SelectedCameraRecordingConfigurationCharacteristic::new(id + 1 + 4, accessory_id), recording_audio_active: Some(RecordingAudioActiveCharacteristic::new(id + 1 + 0 + 5, accessory_id)), ..Default::default() } } } impl HapService for CameraRecordingManagementService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.supported_camera_recording_configuration, &self.supported_video_recording_configuration, &self.supported_audio_recording_configuration, &self.selected_camera_recording_configuration, ]; if let Some(c) = &self.recording_audio_active { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.supported_camera_recording_configuration, &mut self.supported_video_recording_configuration, &mut self.supported_audio_recording_configuration, &mut self.selected_camera_recording_configuration, ]; if let Some(c) = &mut self.recording_audio_active { characteristics.push(c); } characteristics } } impl Serialize for CameraRecordingManagementService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/camera_stream_management.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, selected_stream_configuration::SelectedStreamConfigurationCharacteristic, setup_endpoint::SetupEndpointCharacteristic, streaming_status::StreamingStatusCharacteristic, supported_audio_stream_configuration::SupportedAudioStreamConfigurationCharacteristic, supported_rtp_configuration::SupportedRtpConfigurationCharacteristic, supported_video_stream_configuration::SupportedVideoStreamConfigurationCharacteristic, active::ActiveCharacteristic, }, HapType, }; /// Camera Stream Management service. #[derive(Debug, Default)] pub struct CameraStreamManagementService { /// Instance ID of the Camera Stream Management service. id: u64, /// [`HapType`](HapType) of the Camera Stream Management service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Selected Stream Configuration characteristic (required). pub selected_stream_configuration: SelectedStreamConfigurationCharacteristic, /// Setup Endpoint characteristic (required). pub setup_endpoint: SetupEndpointCharacteristic, /// Streaming Status characteristic (required). pub streaming_status: StreamingStatusCharacteristic, /// Supported Audio Stream Configuration characteristic (required). pub supported_audio_stream_configuration: SupportedAudioStreamConfigurationCharacteristic, /// Supported RTP Configuration characteristic (required). pub supported_rtp_configuration: SupportedRtpConfigurationCharacteristic, /// Supported Video Stream Configuration characteristic (required). pub supported_video_stream_configuration: SupportedVideoStreamConfigurationCharacteristic, /// Active characteristic (optional). pub active: Option, } impl CameraStreamManagementService { /// Creates a new Camera Stream Management service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::CameraStreamManagement, selected_stream_configuration: SelectedStreamConfigurationCharacteristic::new(id + 1 + 0, accessory_id), setup_endpoint: SetupEndpointCharacteristic::new(id + 1 + 1, accessory_id), streaming_status: StreamingStatusCharacteristic::new(id + 1 + 2, accessory_id), supported_audio_stream_configuration: SupportedAudioStreamConfigurationCharacteristic::new(id + 1 + 3, accessory_id), supported_rtp_configuration: SupportedRtpConfigurationCharacteristic::new(id + 1 + 4, accessory_id), supported_video_stream_configuration: SupportedVideoStreamConfigurationCharacteristic::new(id + 1 + 5, accessory_id), active: Some(ActiveCharacteristic::new(id + 1 + 0 + 6, accessory_id)), ..Default::default() } } } impl HapService for CameraStreamManagementService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.selected_stream_configuration, &self.setup_endpoint, &self.streaming_status, &self.supported_audio_stream_configuration, &self.supported_rtp_configuration, &self.supported_video_stream_configuration, ]; if let Some(c) = &self.active { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.selected_stream_configuration, &mut self.setup_endpoint, &mut self.streaming_status, &mut self.supported_audio_stream_configuration, &mut self.supported_rtp_configuration, &mut self.supported_video_stream_configuration, ]; if let Some(c) = &mut self.active { characteristics.push(c); } characteristics } } impl Serialize for CameraStreamManagementService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/carbon_dioxide_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, carbon_dioxide_detected::CarbonDioxideDetectedCharacteristic, carbon_dioxide_level::CarbonDioxideLevelCharacteristic, carbon_dioxide_peak_level::CarbonDioxidePeakLevelCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Carbon dioxide Sensor service. #[derive(Debug, Default)] pub struct CarbonDioxideSensorService { /// Instance ID of the Carbon dioxide Sensor service. id: u64, /// [`HapType`](HapType) of the Carbon dioxide Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Carbon dioxide Detected characteristic (required). pub carbon_dioxide_detected: CarbonDioxideDetectedCharacteristic, /// Carbon dioxide Level characteristic (optional). pub carbon_dioxide_level: Option, /// Carbon dioxide Peak Level characteristic (optional). pub carbon_dioxide_peak_level: Option, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl CarbonDioxideSensorService { /// Creates a new Carbon dioxide Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::CarbonDioxideSensor, carbon_dioxide_detected: CarbonDioxideDetectedCharacteristic::new(id + 1 + 0, accessory_id), carbon_dioxide_level: Some(CarbonDioxideLevelCharacteristic::new(id + 1 + 0 + 1, accessory_id)), carbon_dioxide_peak_level: Some(CarbonDioxidePeakLevelCharacteristic::new(id + 1 + 1 + 1, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 4 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 5 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 6 + 1, accessory_id)), ..Default::default() } } } impl HapService for CarbonDioxideSensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.carbon_dioxide_detected, ]; if let Some(c) = &self.carbon_dioxide_level { characteristics.push(c); } if let Some(c) = &self.carbon_dioxide_peak_level { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.carbon_dioxide_detected, ]; if let Some(c) = &mut self.carbon_dioxide_level { characteristics.push(c); } if let Some(c) = &mut self.carbon_dioxide_peak_level { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for CarbonDioxideSensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/carbon_monoxide_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, carbon_monoxide_detected::CarbonMonoxideDetectedCharacteristic, carbon_monoxide_level::CarbonMonoxideLevelCharacteristic, carbon_monoxide_peak_level::CarbonMonoxidePeakLevelCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Carbon monoxide Sensor service. #[derive(Debug, Default)] pub struct CarbonMonoxideSensorService { /// Instance ID of the Carbon monoxide Sensor service. id: u64, /// [`HapType`](HapType) of the Carbon monoxide Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Carbon monoxide Detected characteristic (required). pub carbon_monoxide_detected: CarbonMonoxideDetectedCharacteristic, /// Carbon monoxide Level characteristic (optional). pub carbon_monoxide_level: Option, /// Carbon monoxide Peak Level characteristic (optional). pub carbon_monoxide_peak_level: Option, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl CarbonMonoxideSensorService { /// Creates a new Carbon monoxide Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::CarbonMonoxideSensor, carbon_monoxide_detected: CarbonMonoxideDetectedCharacteristic::new(id + 1 + 0, accessory_id), carbon_monoxide_level: Some(CarbonMonoxideLevelCharacteristic::new(id + 1 + 0 + 1, accessory_id)), carbon_monoxide_peak_level: Some(CarbonMonoxidePeakLevelCharacteristic::new(id + 1 + 1 + 1, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 4 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 5 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 6 + 1, accessory_id)), ..Default::default() } } } impl HapService for CarbonMonoxideSensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.carbon_monoxide_detected, ]; if let Some(c) = &self.carbon_monoxide_level { characteristics.push(c); } if let Some(c) = &self.carbon_monoxide_peak_level { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.carbon_monoxide_detected, ]; if let Some(c) = &mut self.carbon_monoxide_level { characteristics.push(c); } if let Some(c) = &mut self.carbon_monoxide_peak_level { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for CarbonMonoxideSensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/cloud_relay.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, cloud_relay_control_point::CloudRelayControlPointCharacteristic, cloud_relay_current_state::CloudRelayCurrentStateCharacteristic, cloud_relay_enable_status::CloudRelayEnableStatusCharacteristic, }, HapType, }; /// Cloud Relay service. #[derive(Debug, Default)] pub struct CloudRelayService { /// Instance ID of the Cloud Relay service. id: u64, /// [`HapType`](HapType) of the Cloud Relay service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Cloud Relay Control Point characteristic (required). pub cloud_relay_control_point: CloudRelayControlPointCharacteristic, /// Cloud Relay Current State characteristic (required). pub cloud_relay_current_state: CloudRelayCurrentStateCharacteristic, /// Cloud Relay Enable Status characteristic (required). pub cloud_relay_enable_status: CloudRelayEnableStatusCharacteristic, } impl CloudRelayService { /// Creates a new Cloud Relay service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::CloudRelay, cloud_relay_control_point: CloudRelayControlPointCharacteristic::new(id + 1 + 0, accessory_id), cloud_relay_current_state: CloudRelayCurrentStateCharacteristic::new(id + 1 + 1, accessory_id), cloud_relay_enable_status: CloudRelayEnableStatusCharacteristic::new(id + 1 + 2, accessory_id), ..Default::default() } } } impl HapService for CloudRelayService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.cloud_relay_control_point, &self.cloud_relay_current_state, &self.cloud_relay_enable_status, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.cloud_relay_control_point, &mut self.cloud_relay_current_state, &mut self.cloud_relay_enable_status, ]; characteristics } } impl Serialize for CloudRelayService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/contact_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, contact_sensor_state::ContactSensorStateCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Contact Sensor service. #[derive(Debug, Default)] pub struct ContactSensorService { /// Instance ID of the Contact Sensor service. id: u64, /// [`HapType`](HapType) of the Contact Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Contact Sensor State characteristic (required). pub contact_sensor_state: ContactSensorStateCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl ContactSensorService { /// Creates a new Contact Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::ContactSensor, contact_sensor_state: ContactSensorStateCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 1 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for ContactSensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.contact_sensor_state, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.contact_sensor_state, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for ContactSensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/data_stream_transport_management.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, setup_data_stream_transport::SetupDataStreamTransportCharacteristic, supported_data_stream_transport_configuration::SupportedDataStreamTransportConfigurationCharacteristic, version::VersionCharacteristic, }, HapType, }; /// Data Stream Transport Management service. #[derive(Debug, Default)] pub struct DataStreamTransportManagementService { /// Instance ID of the Data Stream Transport Management service. id: u64, /// [`HapType`](HapType) of the Data Stream Transport Management service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Setup Data Stream Transport characteristic (required). pub setup_data_stream_transport: SetupDataStreamTransportCharacteristic, /// Supported Data Stream Transport Configuration characteristic (required). pub supported_data_stream_transport_configuration: SupportedDataStreamTransportConfigurationCharacteristic, /// Version characteristic (required). pub version: VersionCharacteristic, } impl DataStreamTransportManagementService { /// Creates a new Data Stream Transport Management service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::DataStreamTransportManagement, setup_data_stream_transport: SetupDataStreamTransportCharacteristic::new(id + 1 + 0, accessory_id), supported_data_stream_transport_configuration: SupportedDataStreamTransportConfigurationCharacteristic::new(id + 1 + 1, accessory_id), version: VersionCharacteristic::new(id + 1 + 2, accessory_id), ..Default::default() } } } impl HapService for DataStreamTransportManagementService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.setup_data_stream_transport, &self.supported_data_stream_transport_configuration, &self.version, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.setup_data_stream_transport, &mut self.supported_data_stream_transport_configuration, &mut self.version, ]; characteristics } } impl Serialize for DataStreamTransportManagementService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/diagnostics.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, supported_diagnostics_snapshot::SupportedDiagnosticsSnapshotCharacteristic, selected_diagnostics_modes::SelectedDiagnosticsModesCharacteristic, supported_diagnostics_modes::SupportedDiagnosticsModesCharacteristic, }, HapType, }; /// Diagnostics service. #[derive(Debug, Default)] pub struct DiagnosticsService { /// Instance ID of the Diagnostics service. id: u64, /// [`HapType`](HapType) of the Diagnostics service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Supported Diagnostics Snapshot characteristic (required). pub supported_diagnostics_snapshot: SupportedDiagnosticsSnapshotCharacteristic, /// Selected Diagnostics Modes characteristic (optional). pub selected_diagnostics_modes: Option, /// Supported Diagnostics Modes characteristic (optional). pub supported_diagnostics_modes: Option, } impl DiagnosticsService { /// Creates a new Diagnostics service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Diagnostics, supported_diagnostics_snapshot: SupportedDiagnosticsSnapshotCharacteristic::new(id + 1 + 0, accessory_id), selected_diagnostics_modes: Some(SelectedDiagnosticsModesCharacteristic::new(id + 1 + 0 + 1, accessory_id)), supported_diagnostics_modes: Some(SupportedDiagnosticsModesCharacteristic::new(id + 1 + 1 + 1, accessory_id)), ..Default::default() } } } impl HapService for DiagnosticsService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.supported_diagnostics_snapshot, ]; if let Some(c) = &self.selected_diagnostics_modes { characteristics.push(c); } if let Some(c) = &self.supported_diagnostics_modes { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.supported_diagnostics_snapshot, ]; if let Some(c) = &mut self.selected_diagnostics_modes { characteristics.push(c); } if let Some(c) = &mut self.supported_diagnostics_modes { characteristics.push(c); } characteristics } } impl Serialize for DiagnosticsService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/door.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_position::CurrentPositionCharacteristic, position_state::PositionStateCharacteristic, target_position::TargetPositionCharacteristic, name::NameCharacteristic, obstruction_detected::ObstructionDetectedCharacteristic, hold_position::HoldPositionCharacteristic, }, HapType, }; /// Door service. #[derive(Debug, Default)] pub struct DoorService { /// Instance ID of the Door service. id: u64, /// [`HapType`](HapType) of the Door service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Position characteristic (required). pub current_position: CurrentPositionCharacteristic, /// Position State characteristic (required). pub position_state: PositionStateCharacteristic, /// Target Position characteristic (required). pub target_position: TargetPositionCharacteristic, /// Name characteristic (optional). pub name: Option, /// Obstruction Detected characteristic (optional). pub obstruction_detected: Option, /// Hold Position characteristic (optional). pub hold_position: Option, } impl DoorService { /// Creates a new Door service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Door, current_position: CurrentPositionCharacteristic::new(id + 1 + 0, accessory_id), position_state: PositionStateCharacteristic::new(id + 1 + 1, accessory_id), target_position: TargetPositionCharacteristic::new(id + 1 + 2, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 3, accessory_id)), obstruction_detected: Some(ObstructionDetectedCharacteristic::new(id + 1 + 1 + 3, accessory_id)), hold_position: Some(HoldPositionCharacteristic::new(id + 1 + 2 + 3, accessory_id)), ..Default::default() } } } impl HapService for DoorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_position, &self.position_state, &self.target_position, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.obstruction_detected { characteristics.push(c); } if let Some(c) = &self.hold_position { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_position, &mut self.position_state, &mut self.target_position, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.obstruction_detected { characteristics.push(c); } if let Some(c) = &mut self.hold_position { characteristics.push(c); } characteristics } } impl Serialize for DoorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/doorbell.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, programmable_switch_event::ProgrammableSwitchEventCharacteristic, brightness::BrightnessCharacteristic, mute::MuteCharacteristic, name::NameCharacteristic, operating_state_response::OperatingStateResponseCharacteristic, volume::VolumeCharacteristic, }, HapType, }; /// Doorbell service. #[derive(Debug, Default)] pub struct DoorbellService { /// Instance ID of the Doorbell service. id: u64, /// [`HapType`](HapType) of the Doorbell service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Programmable Switch Event characteristic (required). pub programmable_switch_event: ProgrammableSwitchEventCharacteristic, /// Brightness characteristic (optional). pub brightness: Option, /// Mute characteristic (optional). pub mute: Option, /// Name characteristic (optional). pub name: Option, /// Operating State Response characteristic (optional). pub operating_state_response: Option, /// Volume characteristic (optional). pub volume: Option, } impl DoorbellService { /// Creates a new Doorbell service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Doorbell, programmable_switch_event: ProgrammableSwitchEventCharacteristic::new(id + 1 + 0, accessory_id), brightness: Some(BrightnessCharacteristic::new(id + 1 + 0 + 1, accessory_id)), mute: Some(MuteCharacteristic::new(id + 1 + 1 + 1, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 2 + 1, accessory_id)), operating_state_response: Some(OperatingStateResponseCharacteristic::new(id + 1 + 3 + 1, accessory_id)), volume: Some(VolumeCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for DoorbellService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.programmable_switch_event, ]; if let Some(c) = &self.brightness { characteristics.push(c); } if let Some(c) = &self.mute { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.operating_state_response { characteristics.push(c); } if let Some(c) = &self.volume { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.programmable_switch_event, ]; if let Some(c) = &mut self.brightness { characteristics.push(c); } if let Some(c) = &mut self.mute { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.operating_state_response { characteristics.push(c); } if let Some(c) = &mut self.volume { characteristics.push(c); } characteristics } } impl Serialize for DoorbellService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/fan.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, power_state::PowerStateCharacteristic, name::NameCharacteristic, rotation_direction::RotationDirectionCharacteristic, rotation_speed::RotationSpeedCharacteristic, }, HapType, }; /// Fan service. #[derive(Debug, Default)] pub struct FanService { /// Instance ID of the Fan service. id: u64, /// [`HapType`](HapType) of the Fan service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Power State characteristic (required). pub power_state: PowerStateCharacteristic, /// Name characteristic (optional). pub name: Option, /// Rotation Direction characteristic (optional). pub rotation_direction: Option, /// Rotation Speed characteristic (optional). pub rotation_speed: Option, } impl FanService { /// Creates a new Fan service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Fan, power_state: PowerStateCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), rotation_direction: Some(RotationDirectionCharacteristic::new(id + 1 + 1 + 1, accessory_id)), rotation_speed: Some(RotationSpeedCharacteristic::new(id + 1 + 2 + 1, accessory_id)), ..Default::default() } } } impl HapService for FanService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.power_state, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.rotation_direction { characteristics.push(c); } if let Some(c) = &self.rotation_speed { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.power_state, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.rotation_direction { characteristics.push(c); } if let Some(c) = &mut self.rotation_speed { characteristics.push(c); } characteristics } } impl Serialize for FanService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/fan_v2.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, current_fan_state::CurrentFanStateCharacteristic, target_fan_state::TargetFanStateCharacteristic, lock_physical_controls::LockPhysicalControlsCharacteristic, name::NameCharacteristic, rotation_direction::RotationDirectionCharacteristic, rotation_speed::RotationSpeedCharacteristic, swing_mode::SwingModeCharacteristic, }, HapType, }; /// Fan v2 service. #[derive(Debug, Default)] pub struct FanV2Service { /// Instance ID of the Fan v2 service. id: u64, /// [`HapType`](HapType) of the Fan v2 service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Current Fan State characteristic (optional). pub current_fan_state: Option, /// Target Fan State characteristic (optional). pub target_fan_state: Option, /// Lock Physical Controls characteristic (optional). pub lock_physical_controls: Option, /// Name characteristic (optional). pub name: Option, /// Rotation Direction characteristic (optional). pub rotation_direction: Option, /// Rotation Speed characteristic (optional). pub rotation_speed: Option, /// Swing Mode characteristic (optional). pub swing_mode: Option, } impl FanV2Service { /// Creates a new Fan v2 service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::FanV2, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), current_fan_state: Some(CurrentFanStateCharacteristic::new(id + 1 + 0 + 1, accessory_id)), target_fan_state: Some(TargetFanStateCharacteristic::new(id + 1 + 1 + 1, accessory_id)), lock_physical_controls: Some(LockPhysicalControlsCharacteristic::new(id + 1 + 2 + 1, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 3 + 1, accessory_id)), rotation_direction: Some(RotationDirectionCharacteristic::new(id + 1 + 4 + 1, accessory_id)), rotation_speed: Some(RotationSpeedCharacteristic::new(id + 1 + 5 + 1, accessory_id)), swing_mode: Some(SwingModeCharacteristic::new(id + 1 + 6 + 1, accessory_id)), ..Default::default() } } } impl HapService for FanV2Service { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, ]; if let Some(c) = &self.current_fan_state { characteristics.push(c); } if let Some(c) = &self.target_fan_state { characteristics.push(c); } if let Some(c) = &self.lock_physical_controls { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.rotation_direction { characteristics.push(c); } if let Some(c) = &self.rotation_speed { characteristics.push(c); } if let Some(c) = &self.swing_mode { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, ]; if let Some(c) = &mut self.current_fan_state { characteristics.push(c); } if let Some(c) = &mut self.target_fan_state { characteristics.push(c); } if let Some(c) = &mut self.lock_physical_controls { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.rotation_direction { characteristics.push(c); } if let Some(c) = &mut self.rotation_speed { characteristics.push(c); } if let Some(c) = &mut self.swing_mode { characteristics.push(c); } characteristics } } impl Serialize for FanV2Service { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/faucet.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, name::NameCharacteristic, status_fault::StatusFaultCharacteristic, }, HapType, }; /// Faucet service. #[derive(Debug, Default)] pub struct FaucetService { /// Instance ID of the Faucet service. id: u64, /// [`HapType`](HapType) of the Faucet service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Fault characteristic (optional). pub status_fault: Option, } impl FaucetService { /// Creates a new Faucet service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Faucet, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 1 + 1, accessory_id)), ..Default::default() } } } impl HapService for FaucetService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } characteristics } } impl Serialize for FaucetService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/filter_maintenance.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, filter_change_indication::FilterChangeIndicationCharacteristic, filter_life_level::FilterLifeLevelCharacteristic, filter_reset_change_indication::FilterResetChangeIndicationCharacteristic, name::NameCharacteristic, }, HapType, }; /// Filter Maintenance service. #[derive(Debug, Default)] pub struct FilterMaintenanceService { /// Instance ID of the Filter Maintenance service. id: u64, /// [`HapType`](HapType) of the Filter Maintenance service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Filter Change indication characteristic (required). pub filter_change_indication: FilterChangeIndicationCharacteristic, /// Filter Life Level characteristic (optional). pub filter_life_level: Option, /// Filter Reset Change Indication characteristic (optional). pub filter_reset_change_indication: Option, /// Name characteristic (optional). pub name: Option, } impl FilterMaintenanceService { /// Creates a new Filter Maintenance service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::FilterMaintenance, filter_change_indication: FilterChangeIndicationCharacteristic::new(id + 1 + 0, accessory_id), filter_life_level: Some(FilterLifeLevelCharacteristic::new(id + 1 + 0 + 1, accessory_id)), filter_reset_change_indication: Some(FilterResetChangeIndicationCharacteristic::new(id + 1 + 1 + 1, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 2 + 1, accessory_id)), ..Default::default() } } } impl HapService for FilterMaintenanceService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.filter_change_indication, ]; if let Some(c) = &self.filter_life_level { characteristics.push(c); } if let Some(c) = &self.filter_reset_change_indication { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.filter_change_indication, ]; if let Some(c) = &mut self.filter_life_level { characteristics.push(c); } if let Some(c) = &mut self.filter_reset_change_indication { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } characteristics } } impl Serialize for FilterMaintenanceService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/garage_door_opener.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_door_state::CurrentDoorStateCharacteristic, target_door_state::TargetDoorStateCharacteristic, obstruction_detected::ObstructionDetectedCharacteristic, lock_current_state::LockCurrentStateCharacteristic, lock_target_state::LockTargetStateCharacteristic, name::NameCharacteristic, }, HapType, }; /// Garage Door Opener service. #[derive(Debug, Default)] pub struct GarageDoorOpenerService { /// Instance ID of the Garage Door Opener service. id: u64, /// [`HapType`](HapType) of the Garage Door Opener service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Door State characteristic (required). pub current_door_state: CurrentDoorStateCharacteristic, /// Target Door State characteristic (required). pub target_door_state: TargetDoorStateCharacteristic, /// Obstruction Detected characteristic (required). pub obstruction_detected: ObstructionDetectedCharacteristic, /// Lock Current State characteristic (optional). pub lock_current_state: Option, /// Lock Target State characteristic (optional). pub lock_target_state: Option, /// Name characteristic (optional). pub name: Option, } impl GarageDoorOpenerService { /// Creates a new Garage Door Opener service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::GarageDoorOpener, current_door_state: CurrentDoorStateCharacteristic::new(id + 1 + 0, accessory_id), target_door_state: TargetDoorStateCharacteristic::new(id + 1 + 1, accessory_id), obstruction_detected: ObstructionDetectedCharacteristic::new(id + 1 + 2, accessory_id), lock_current_state: Some(LockCurrentStateCharacteristic::new(id + 1 + 0 + 3, accessory_id)), lock_target_state: Some(LockTargetStateCharacteristic::new(id + 1 + 1 + 3, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 2 + 3, accessory_id)), ..Default::default() } } } impl HapService for GarageDoorOpenerService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_door_state, &self.target_door_state, &self.obstruction_detected, ]; if let Some(c) = &self.lock_current_state { characteristics.push(c); } if let Some(c) = &self.lock_target_state { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_door_state, &mut self.target_door_state, &mut self.obstruction_detected, ]; if let Some(c) = &mut self.lock_current_state { characteristics.push(c); } if let Some(c) = &mut self.lock_target_state { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } characteristics } } impl Serialize for GarageDoorOpenerService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/heater_cooler.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, current_heater_cooler_state::CurrentHeaterCoolerStateCharacteristic, target_heater_cooler_state::TargetHeaterCoolerStateCharacteristic, current_temperature::CurrentTemperatureCharacteristic, lock_physical_controls::LockPhysicalControlsCharacteristic, name::NameCharacteristic, rotation_speed::RotationSpeedCharacteristic, swing_mode::SwingModeCharacteristic, cooling_threshold_temperature::CoolingThresholdTemperatureCharacteristic, heating_threshold_temperature::HeatingThresholdTemperatureCharacteristic, temperature_display_units::TemperatureDisplayUnitsCharacteristic, }, HapType, }; /// Heater-Cooler service. #[derive(Debug, Default)] pub struct HeaterCoolerService { /// Instance ID of the Heater-Cooler service. id: u64, /// [`HapType`](HapType) of the Heater-Cooler service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Current Heater-Cooler State characteristic (required). pub current_heater_cooler_state: CurrentHeaterCoolerStateCharacteristic, /// Target Heater-Cooler State characteristic (required). pub target_heater_cooler_state: TargetHeaterCoolerStateCharacteristic, /// Current Temperature characteristic (required). pub current_temperature: CurrentTemperatureCharacteristic, /// Lock Physical Controls characteristic (optional). pub lock_physical_controls: Option, /// Name characteristic (optional). pub name: Option, /// Rotation Speed characteristic (optional). pub rotation_speed: Option, /// Swing Mode characteristic (optional). pub swing_mode: Option, /// Cooling Threshold Temperature characteristic (optional). pub cooling_threshold_temperature: Option, /// Heating Threshold Temperature characteristic (optional). pub heating_threshold_temperature: Option, /// Temperature Display Units characteristic (optional). pub temperature_display_units: Option, } impl HeaterCoolerService { /// Creates a new Heater-Cooler service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::HeaterCooler, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), current_heater_cooler_state: CurrentHeaterCoolerStateCharacteristic::new(id + 1 + 1, accessory_id), target_heater_cooler_state: TargetHeaterCoolerStateCharacteristic::new(id + 1 + 2, accessory_id), current_temperature: CurrentTemperatureCharacteristic::new(id + 1 + 3, accessory_id), lock_physical_controls: Some(LockPhysicalControlsCharacteristic::new(id + 1 + 0 + 4, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 1 + 4, accessory_id)), rotation_speed: Some(RotationSpeedCharacteristic::new(id + 1 + 2 + 4, accessory_id)), swing_mode: Some(SwingModeCharacteristic::new(id + 1 + 3 + 4, accessory_id)), cooling_threshold_temperature: Some(CoolingThresholdTemperatureCharacteristic::new(id + 1 + 4 + 4, accessory_id)), heating_threshold_temperature: Some(HeatingThresholdTemperatureCharacteristic::new(id + 1 + 5 + 4, accessory_id)), temperature_display_units: Some(TemperatureDisplayUnitsCharacteristic::new(id + 1 + 6 + 4, accessory_id)), ..Default::default() } } } impl HapService for HeaterCoolerService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.current_heater_cooler_state, &self.target_heater_cooler_state, &self.current_temperature, ]; if let Some(c) = &self.lock_physical_controls { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.rotation_speed { characteristics.push(c); } if let Some(c) = &self.swing_mode { characteristics.push(c); } if let Some(c) = &self.cooling_threshold_temperature { characteristics.push(c); } if let Some(c) = &self.heating_threshold_temperature { characteristics.push(c); } if let Some(c) = &self.temperature_display_units { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.current_heater_cooler_state, &mut self.target_heater_cooler_state, &mut self.current_temperature, ]; if let Some(c) = &mut self.lock_physical_controls { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.rotation_speed { characteristics.push(c); } if let Some(c) = &mut self.swing_mode { characteristics.push(c); } if let Some(c) = &mut self.cooling_threshold_temperature { characteristics.push(c); } if let Some(c) = &mut self.heating_threshold_temperature { characteristics.push(c); } if let Some(c) = &mut self.temperature_display_units { characteristics.push(c); } characteristics } } impl Serialize for HeaterCoolerService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/humidifier_dehumidifier.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, current_humidifier_dehumidifier_state::CurrentHumidifierDehumidifierStateCharacteristic, target_humidifier_dehumidifier_state::TargetHumidifierDehumidifierStateCharacteristic, current_relative_humidity::CurrentRelativeHumidityCharacteristic, lock_physical_controls::LockPhysicalControlsCharacteristic, name::NameCharacteristic, relative_humidity_dehumidifier_threshold::RelativeHumidityDehumidifierThresholdCharacteristic, relative_humidity_humidifier_threshold::RelativeHumidityHumidifierThresholdCharacteristic, rotation_speed::RotationSpeedCharacteristic, swing_mode::SwingModeCharacteristic, current_water_level::CurrentWaterLevelCharacteristic, }, HapType, }; /// Humidifier-Dehumidifier service. #[derive(Debug, Default)] pub struct HumidifierDehumidifierService { /// Instance ID of the Humidifier-Dehumidifier service. id: u64, /// [`HapType`](HapType) of the Humidifier-Dehumidifier service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Current Humidifier-Dehumidifier State characteristic (required). pub current_humidifier_dehumidifier_state: CurrentHumidifierDehumidifierStateCharacteristic, /// Target Humidifier-Dehumidifier State characteristic (required). pub target_humidifier_dehumidifier_state: TargetHumidifierDehumidifierStateCharacteristic, /// Current Relative Humidity characteristic (required). pub current_relative_humidity: CurrentRelativeHumidityCharacteristic, /// Lock Physical Controls characteristic (optional). pub lock_physical_controls: Option, /// Name characteristic (optional). pub name: Option, /// Relative Humidity Dehumidifier Threshold characteristic (optional). pub relative_humidity_dehumidifier_threshold: Option, /// Relative Humidity Humidifier Threshold characteristic (optional). pub relative_humidity_humidifier_threshold: Option, /// Rotation Speed characteristic (optional). pub rotation_speed: Option, /// Swing Mode characteristic (optional). pub swing_mode: Option, /// Current Water Level characteristic (optional). pub current_water_level: Option, } impl HumidifierDehumidifierService { /// Creates a new Humidifier-Dehumidifier service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::HumidifierDehumidifier, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), current_humidifier_dehumidifier_state: CurrentHumidifierDehumidifierStateCharacteristic::new(id + 1 + 1, accessory_id), target_humidifier_dehumidifier_state: TargetHumidifierDehumidifierStateCharacteristic::new(id + 1 + 2, accessory_id), current_relative_humidity: CurrentRelativeHumidityCharacteristic::new(id + 1 + 3, accessory_id), lock_physical_controls: Some(LockPhysicalControlsCharacteristic::new(id + 1 + 0 + 4, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 1 + 4, accessory_id)), relative_humidity_dehumidifier_threshold: Some(RelativeHumidityDehumidifierThresholdCharacteristic::new(id + 1 + 2 + 4, accessory_id)), relative_humidity_humidifier_threshold: Some(RelativeHumidityHumidifierThresholdCharacteristic::new(id + 1 + 3 + 4, accessory_id)), rotation_speed: Some(RotationSpeedCharacteristic::new(id + 1 + 4 + 4, accessory_id)), swing_mode: Some(SwingModeCharacteristic::new(id + 1 + 5 + 4, accessory_id)), current_water_level: Some(CurrentWaterLevelCharacteristic::new(id + 1 + 6 + 4, accessory_id)), ..Default::default() } } } impl HapService for HumidifierDehumidifierService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.current_humidifier_dehumidifier_state, &self.target_humidifier_dehumidifier_state, &self.current_relative_humidity, ]; if let Some(c) = &self.lock_physical_controls { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.relative_humidity_dehumidifier_threshold { characteristics.push(c); } if let Some(c) = &self.relative_humidity_humidifier_threshold { characteristics.push(c); } if let Some(c) = &self.rotation_speed { characteristics.push(c); } if let Some(c) = &self.swing_mode { characteristics.push(c); } if let Some(c) = &self.current_water_level { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.current_humidifier_dehumidifier_state, &mut self.target_humidifier_dehumidifier_state, &mut self.current_relative_humidity, ]; if let Some(c) = &mut self.lock_physical_controls { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.relative_humidity_dehumidifier_threshold { characteristics.push(c); } if let Some(c) = &mut self.relative_humidity_humidifier_threshold { characteristics.push(c); } if let Some(c) = &mut self.rotation_speed { characteristics.push(c); } if let Some(c) = &mut self.swing_mode { characteristics.push(c); } if let Some(c) = &mut self.current_water_level { characteristics.push(c); } characteristics } } impl Serialize for HumidifierDehumidifierService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/humidity_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_relative_humidity::CurrentRelativeHumidityCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Humidity Sensor service. #[derive(Debug, Default)] pub struct HumiditySensorService { /// Instance ID of the Humidity Sensor service. id: u64, /// [`HapType`](HapType) of the Humidity Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Relative Humidity characteristic (required). pub current_relative_humidity: CurrentRelativeHumidityCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl HumiditySensorService { /// Creates a new Humidity Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::HumiditySensor, current_relative_humidity: CurrentRelativeHumidityCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 1 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for HumiditySensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_relative_humidity, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_relative_humidity, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for HumiditySensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/input_source.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, configured_name::ConfiguredNameCharacteristic, input_source_type::InputSourceTypeCharacteristic, is_configured::IsConfiguredCharacteristic, name::NameCharacteristic, current_visibility_state::CurrentVisibilityStateCharacteristic, identifier::IdentifierCharacteristic, input_device_type::InputDeviceTypeCharacteristic, target_visibility_state::TargetVisibilityStateCharacteristic, }, HapType, }; /// Input Source service. #[derive(Debug, Default)] pub struct InputSourceService { /// Instance ID of the Input Source service. id: u64, /// [`HapType`](HapType) of the Input Source service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Configured Name characteristic (required). pub configured_name: ConfiguredNameCharacteristic, /// Input Source Type characteristic (required). pub input_source_type: InputSourceTypeCharacteristic, /// Is Configured characteristic (required). pub is_configured: IsConfiguredCharacteristic, /// Name characteristic (required). pub name: NameCharacteristic, /// Current Visibility State characteristic (required). pub current_visibility_state: CurrentVisibilityStateCharacteristic, /// Identifier characteristic (optional). pub identifier: Option, /// Input Device Type characteristic (optional). pub input_device_type: Option, /// Target Visibility State characteristic (optional). pub target_visibility_state: Option, } impl InputSourceService { /// Creates a new Input Source service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::InputSource, configured_name: ConfiguredNameCharacteristic::new(id + 1 + 0, accessory_id), input_source_type: InputSourceTypeCharacteristic::new(id + 1 + 1, accessory_id), is_configured: IsConfiguredCharacteristic::new(id + 1 + 2, accessory_id), name: NameCharacteristic::new(id + 1 + 3, accessory_id), current_visibility_state: CurrentVisibilityStateCharacteristic::new(id + 1 + 4, accessory_id), identifier: Some(IdentifierCharacteristic::new(id + 1 + 0 + 5, accessory_id)), input_device_type: Some(InputDeviceTypeCharacteristic::new(id + 1 + 1 + 5, accessory_id)), target_visibility_state: Some(TargetVisibilityStateCharacteristic::new(id + 1 + 2 + 5, accessory_id)), ..Default::default() } } } impl HapService for InputSourceService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.configured_name, &self.input_source_type, &self.is_configured, &self.name, &self.current_visibility_state, ]; if let Some(c) = &self.identifier { characteristics.push(c); } if let Some(c) = &self.input_device_type { characteristics.push(c); } if let Some(c) = &self.target_visibility_state { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.configured_name, &mut self.input_source_type, &mut self.is_configured, &mut self.name, &mut self.current_visibility_state, ]; if let Some(c) = &mut self.identifier { characteristics.push(c); } if let Some(c) = &mut self.input_device_type { characteristics.push(c); } if let Some(c) = &mut self.target_visibility_state { characteristics.push(c); } characteristics } } impl Serialize for InputSourceService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/irrigation_system.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, program_mode::ProgramModeCharacteristic, in_use::InUseCharacteristic, remaining_duration::RemainingDurationCharacteristic, name::NameCharacteristic, status_fault::StatusFaultCharacteristic, }, HapType, }; /// Irrigation-System service. #[derive(Debug, Default)] pub struct IrrigationSystemService { /// Instance ID of the Irrigation-System service. id: u64, /// [`HapType`](HapType) of the Irrigation-System service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Program Mode characteristic (required). pub program_mode: ProgramModeCharacteristic, /// In Use characteristic (required). pub in_use: InUseCharacteristic, /// Remaining Duration characteristic (optional). pub remaining_duration: Option, /// Name characteristic (optional). pub name: Option, /// Status Fault characteristic (optional). pub status_fault: Option, } impl IrrigationSystemService { /// Creates a new Irrigation-System service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::IrrigationSystem, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), program_mode: ProgramModeCharacteristic::new(id + 1 + 1, accessory_id), in_use: InUseCharacteristic::new(id + 1 + 2, accessory_id), remaining_duration: Some(RemainingDurationCharacteristic::new(id + 1 + 0 + 3, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 1 + 3, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 3, accessory_id)), ..Default::default() } } } impl HapService for IrrigationSystemService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.program_mode, &self.in_use, ]; if let Some(c) = &self.remaining_duration { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.program_mode, &mut self.in_use, ]; if let Some(c) = &mut self.remaining_duration { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } characteristics } } impl Serialize for IrrigationSystemService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/label.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, label_namespace::LabelNamespaceCharacteristic, }, HapType, }; /// Label service. #[derive(Debug, Default)] pub struct LabelService { /// Instance ID of the Label service. id: u64, /// [`HapType`](HapType) of the Label service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Label Namespace characteristic (required). pub label_namespace: LabelNamespaceCharacteristic, } impl LabelService { /// Creates a new Label service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Label, label_namespace: LabelNamespaceCharacteristic::new(id + 1 + 0, accessory_id), ..Default::default() } } } impl HapService for LabelService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.label_namespace, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.label_namespace, ]; characteristics } } impl Serialize for LabelService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/leak_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, leak_detected::LeakDetectedCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Leak Sensor service. #[derive(Debug, Default)] pub struct LeakSensorService { /// Instance ID of the Leak Sensor service. id: u64, /// [`HapType`](HapType) of the Leak Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Leak Detected characteristic (required). pub leak_detected: LeakDetectedCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl LeakSensorService { /// Creates a new Leak Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::LeakSensor, leak_detected: LeakDetectedCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 1 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for LeakSensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.leak_detected, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.leak_detected, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for LeakSensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/light_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_light_level::CurrentLightLevelCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Light Sensor service. #[derive(Debug, Default)] pub struct LightSensorService { /// Instance ID of the Light Sensor service. id: u64, /// [`HapType`](HapType) of the Light Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Light Level characteristic (required). pub current_light_level: CurrentLightLevelCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl LightSensorService { /// Creates a new Light Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::LightSensor, current_light_level: CurrentLightLevelCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 1 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for LightSensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_light_level, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_light_level, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for LightSensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/lightbulb.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, power_state::PowerStateCharacteristic, brightness::BrightnessCharacteristic, characteristic_value_active_transition_count::CharacteristicValueActiveTransitionCountCharacteristic, characteristic_value_transition_control::CharacteristicValueTransitionControlCharacteristic, color_temperature::ColorTemperatureCharacteristic, hue::HueCharacteristic, name::NameCharacteristic, saturation::SaturationCharacteristic, supported_characteristic_value_transition_configuration::SupportedCharacteristicValueTransitionConfigurationCharacteristic, }, HapType, }; /// Lightbulb service. #[derive(Debug, Default)] pub struct LightbulbService { /// Instance ID of the Lightbulb service. id: u64, /// [`HapType`](HapType) of the Lightbulb service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Power State characteristic (required). pub power_state: PowerStateCharacteristic, /// Brightness characteristic (optional). pub brightness: Option, /// Characteristic Value Active Transition Count characteristic (optional). pub characteristic_value_active_transition_count: Option, /// Characteristic Value Transition Control characteristic (optional). pub characteristic_value_transition_control: Option, /// Color Temperature characteristic (optional). pub color_temperature: Option, /// Hue characteristic (optional). pub hue: Option, /// Name characteristic (optional). pub name: Option, /// Saturation characteristic (optional). pub saturation: Option, /// Supported Characteristic Value Transition Configuration characteristic (optional). pub supported_characteristic_value_transition_configuration: Option, } impl LightbulbService { /// Creates a new Lightbulb service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Lightbulb, power_state: PowerStateCharacteristic::new(id + 1 + 0, accessory_id), brightness: Some(BrightnessCharacteristic::new(id + 1 + 0 + 1, accessory_id)), characteristic_value_active_transition_count: Some(CharacteristicValueActiveTransitionCountCharacteristic::new(id + 1 + 1 + 1, accessory_id)), characteristic_value_transition_control: Some(CharacteristicValueTransitionControlCharacteristic::new(id + 1 + 2 + 1, accessory_id)), color_temperature: Some(ColorTemperatureCharacteristic::new(id + 1 + 3 + 1, accessory_id)), hue: Some(HueCharacteristic::new(id + 1 + 4 + 1, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 5 + 1, accessory_id)), saturation: Some(SaturationCharacteristic::new(id + 1 + 6 + 1, accessory_id)), supported_characteristic_value_transition_configuration: Some(SupportedCharacteristicValueTransitionConfigurationCharacteristic::new(id + 1 + 7 + 1, accessory_id)), ..Default::default() } } } impl HapService for LightbulbService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.power_state, ]; if let Some(c) = &self.brightness { characteristics.push(c); } if let Some(c) = &self.characteristic_value_active_transition_count { characteristics.push(c); } if let Some(c) = &self.characteristic_value_transition_control { characteristics.push(c); } if let Some(c) = &self.color_temperature { characteristics.push(c); } if let Some(c) = &self.hue { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.saturation { characteristics.push(c); } if let Some(c) = &self.supported_characteristic_value_transition_configuration { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.power_state, ]; if let Some(c) = &mut self.brightness { characteristics.push(c); } if let Some(c) = &mut self.characteristic_value_active_transition_count { characteristics.push(c); } if let Some(c) = &mut self.characteristic_value_transition_control { characteristics.push(c); } if let Some(c) = &mut self.color_temperature { characteristics.push(c); } if let Some(c) = &mut self.hue { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.saturation { characteristics.push(c); } if let Some(c) = &mut self.supported_characteristic_value_transition_configuration { characteristics.push(c); } characteristics } } impl Serialize for LightbulbService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/lock_management.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, lock_control_point::LockControlPointCharacteristic, version::VersionCharacteristic, administrator_only_access::AdministratorOnlyAccessCharacteristic, audio_feedback::AudioFeedbackCharacteristic, current_door_state::CurrentDoorStateCharacteristic, lock_management_auto_security_timeout::LockManagementAutoSecurityTimeoutCharacteristic, lock_last_known_action::LockLastKnownActionCharacteristic, logs::LogsCharacteristic, motion_detected::MotionDetectedCharacteristic, }, HapType, }; /// Lock Management service. #[derive(Debug, Default)] pub struct LockManagementService { /// Instance ID of the Lock Management service. id: u64, /// [`HapType`](HapType) of the Lock Management service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Lock Control Point characteristic (required). pub lock_control_point: LockControlPointCharacteristic, /// Version characteristic (required). pub version: VersionCharacteristic, /// Administrator Only Access characteristic (optional). pub administrator_only_access: Option, /// Audio Feedback characteristic (optional). pub audio_feedback: Option, /// Current Door State characteristic (optional). pub current_door_state: Option, /// Lock Management Auto Security Timeout characteristic (optional). pub lock_management_auto_security_timeout: Option, /// Lock Last Known Action characteristic (optional). pub lock_last_known_action: Option, /// Logs characteristic (optional). pub logs: Option, /// Motion Detected characteristic (optional). pub motion_detected: Option, } impl LockManagementService { /// Creates a new Lock Management service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::LockManagement, lock_control_point: LockControlPointCharacteristic::new(id + 1 + 0, accessory_id), version: VersionCharacteristic::new(id + 1 + 1, accessory_id), administrator_only_access: Some(AdministratorOnlyAccessCharacteristic::new(id + 1 + 0 + 2, accessory_id)), audio_feedback: Some(AudioFeedbackCharacteristic::new(id + 1 + 1 + 2, accessory_id)), current_door_state: Some(CurrentDoorStateCharacteristic::new(id + 1 + 2 + 2, accessory_id)), lock_management_auto_security_timeout: Some(LockManagementAutoSecurityTimeoutCharacteristic::new(id + 1 + 3 + 2, accessory_id)), lock_last_known_action: Some(LockLastKnownActionCharacteristic::new(id + 1 + 4 + 2, accessory_id)), logs: Some(LogsCharacteristic::new(id + 1 + 5 + 2, accessory_id)), motion_detected: Some(MotionDetectedCharacteristic::new(id + 1 + 6 + 2, accessory_id)), ..Default::default() } } } impl HapService for LockManagementService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.lock_control_point, &self.version, ]; if let Some(c) = &self.administrator_only_access { characteristics.push(c); } if let Some(c) = &self.audio_feedback { characteristics.push(c); } if let Some(c) = &self.current_door_state { characteristics.push(c); } if let Some(c) = &self.lock_management_auto_security_timeout { characteristics.push(c); } if let Some(c) = &self.lock_last_known_action { characteristics.push(c); } if let Some(c) = &self.logs { characteristics.push(c); } if let Some(c) = &self.motion_detected { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.lock_control_point, &mut self.version, ]; if let Some(c) = &mut self.administrator_only_access { characteristics.push(c); } if let Some(c) = &mut self.audio_feedback { characteristics.push(c); } if let Some(c) = &mut self.current_door_state { characteristics.push(c); } if let Some(c) = &mut self.lock_management_auto_security_timeout { characteristics.push(c); } if let Some(c) = &mut self.lock_last_known_action { characteristics.push(c); } if let Some(c) = &mut self.logs { characteristics.push(c); } if let Some(c) = &mut self.motion_detected { characteristics.push(c); } characteristics } } impl Serialize for LockManagementService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/lock_mechanism.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, lock_current_state::LockCurrentStateCharacteristic, lock_target_state::LockTargetStateCharacteristic, name::NameCharacteristic, }, HapType, }; /// Lock Mechanism service. #[derive(Debug, Default)] pub struct LockMechanismService { /// Instance ID of the Lock Mechanism service. id: u64, /// [`HapType`](HapType) of the Lock Mechanism service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Lock Current State characteristic (required). pub lock_current_state: LockCurrentStateCharacteristic, /// Lock Target State characteristic (required). pub lock_target_state: LockTargetStateCharacteristic, /// Name characteristic (optional). pub name: Option, } impl LockMechanismService { /// Creates a new Lock Mechanism service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::LockMechanism, lock_current_state: LockCurrentStateCharacteristic::new(id + 1 + 0, accessory_id), lock_target_state: LockTargetStateCharacteristic::new(id + 1 + 1, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 2, accessory_id)), ..Default::default() } } } impl HapService for LockMechanismService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.lock_current_state, &self.lock_target_state, ]; if let Some(c) = &self.name { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.lock_current_state, &mut self.lock_target_state, ]; if let Some(c) = &mut self.name { characteristics.push(c); } characteristics } } impl Serialize for LockMechanismService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/microphone.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, mute::MuteCharacteristic, volume::VolumeCharacteristic, }, HapType, }; /// Microphone service. #[derive(Debug, Default)] pub struct MicrophoneService { /// Instance ID of the Microphone service. id: u64, /// [`HapType`](HapType) of the Microphone service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Mute characteristic (required). pub mute: MuteCharacteristic, /// Volume characteristic (optional). pub volume: Option, } impl MicrophoneService { /// Creates a new Microphone service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Microphone, mute: MuteCharacteristic::new(id + 1 + 0, accessory_id), volume: Some(VolumeCharacteristic::new(id + 1 + 0 + 1, accessory_id)), ..Default::default() } } } impl HapService for MicrophoneService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.mute, ]; if let Some(c) = &self.volume { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.mute, ]; if let Some(c) = &mut self.volume { characteristics.push(c); } characteristics } } impl Serialize for MicrophoneService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/mod.rs ================================================ // this file is auto-generated by hap-codegen /// Access Code service definition. pub mod access_code; /// Access Control service definition. pub mod access_control; /// Accessory Information service definition. pub mod accessory_information; /// Accessory Metrics service definition. pub mod accessory_metrics; /// Accessory Runtime Information service definition. pub mod accessory_runtime_information; /// Air Purifier service definition. pub mod air_purifier; /// Air Quality Sensor service definition. pub mod air_quality_sensor; /// Asset Update service definition. pub mod asset_update; /// Assistant service definition. pub mod assistant; /// Audio Stream Management service definition. pub mod audio_stream_management; /// Battery service definition. pub mod battery; /// Camera Operating Mode service definition. pub mod camera_operating_mode; /// Camera Recording Management service definition. pub mod camera_recording_management; /// Camera Stream Management service definition. pub mod camera_stream_management; /// Carbon dioxide Sensor service definition. pub mod carbon_dioxide_sensor; /// Carbon monoxide Sensor service definition. pub mod carbon_monoxide_sensor; /// Cloud Relay service definition. pub mod cloud_relay; /// Contact Sensor service definition. pub mod contact_sensor; /// Data Stream Transport Management service definition. pub mod data_stream_transport_management; /// Diagnostics service definition. pub mod diagnostics; /// Door service definition. pub mod door; /// Doorbell service definition. pub mod doorbell; /// Fan service definition. pub mod fan; /// Fan v2 service definition. pub mod fan_v2; /// Faucet service definition. pub mod faucet; /// Filter Maintenance service definition. pub mod filter_maintenance; /// Garage Door Opener service definition. pub mod garage_door_opener; /// Heater-Cooler service definition. pub mod heater_cooler; /// Humidifier-Dehumidifier service definition. pub mod humidifier_dehumidifier; /// Humidity Sensor service definition. pub mod humidity_sensor; /// Input Source service definition. pub mod input_source; /// Irrigation-System service definition. pub mod irrigation_system; /// Label service definition. pub mod label; /// Leak Sensor service definition. pub mod leak_sensor; /// Light Sensor service definition. pub mod light_sensor; /// Lightbulb service definition. pub mod lightbulb; /// Lock Management service definition. pub mod lock_management; /// Lock Mechanism service definition. pub mod lock_mechanism; /// Microphone service definition. pub mod microphone; /// Motion Sensor service definition. pub mod motion_sensor; /// NFC Access Service service definition. pub mod nfc_access_service; /// Occupancy Sensor service definition. pub mod occupancy_sensor; /// Outlet service definition. pub mod outlet; /// Pairing service definition. pub mod pairing; /// Power Management service definition. pub mod power_management; /// Protocol Information service definition. pub mod protocol_information; /// Security System service definition. pub mod security_system; /// Siri service definition. pub mod siri; /// Siri Endpoint service definition. pub mod siri_endpoint; /// Slats service definition. pub mod slats; /// Smart Speaker service definition. pub mod smart_speaker; /// Smoke Sensor service definition. pub mod smoke_sensor; /// Speaker service definition. pub mod speaker; /// Stateful Programmable Switch service definition. pub mod stateful_programmable_switch; /// Stateless Programmable Switch service definition. pub mod stateless_programmable_switch; /// Switch service definition. pub mod switch; /// Target Control service definition. pub mod target_control; /// Target Control Management service definition. pub mod target_control_management; /// Television service definition. pub mod television; /// Temperature Sensor service definition. pub mod temperature_sensor; /// Thermostat service definition. pub mod thermostat; /// Thread Transport service definition. pub mod thread_transport; /// Transfer Transport Management service definition. pub mod transfer_transport_management; /// Valve service definition. pub mod valve; /// Wi-Fi Router service definition. pub mod wi_fi_router; /// Wi-Fi Satellite service definition. pub mod wi_fi_satellite; /// Wi-Fi Transport service definition. pub mod wi_fi_transport; /// Window service definition. pub mod window; /// Window Covering service definition. pub mod window_covering; ================================================ FILE: src/service/generated/motion_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, motion_detected::MotionDetectedCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Motion Sensor service. #[derive(Debug, Default)] pub struct MotionSensorService { /// Instance ID of the Motion Sensor service. id: u64, /// [`HapType`](HapType) of the Motion Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Motion Detected characteristic (required). pub motion_detected: MotionDetectedCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl MotionSensorService { /// Creates a new Motion Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::MotionSensor, motion_detected: MotionDetectedCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 1 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for MotionSensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.motion_detected, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.motion_detected, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for MotionSensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/nfc_access_service.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, configuration_state::ConfigurationStateCharacteristic, nfc_access_control_point::NfcAccessControlPointCharacteristic, nfc_access_supported_configuration::NfcAccessSupportedConfigurationCharacteristic, }, HapType, }; /// NFC Access Service service. #[derive(Debug, Default)] pub struct NfcAccessServiceService { /// Instance ID of the NFC Access Service service. id: u64, /// [`HapType`](HapType) of the NFC Access Service service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Configuration State characteristic (required). pub configuration_state: ConfigurationStateCharacteristic, /// NFC Access Control Point characteristic (required). pub nfc_access_control_point: NfcAccessControlPointCharacteristic, /// NFC Access Supported Configuration characteristic (required). pub nfc_access_supported_configuration: NfcAccessSupportedConfigurationCharacteristic, } impl NfcAccessServiceService { /// Creates a new NFC Access Service service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::NfcAccessService, configuration_state: ConfigurationStateCharacteristic::new(id + 1 + 0, accessory_id), nfc_access_control_point: NfcAccessControlPointCharacteristic::new(id + 1 + 1, accessory_id), nfc_access_supported_configuration: NfcAccessSupportedConfigurationCharacteristic::new(id + 1 + 2, accessory_id), ..Default::default() } } } impl HapService for NfcAccessServiceService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.configuration_state, &self.nfc_access_control_point, &self.nfc_access_supported_configuration, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.configuration_state, &mut self.nfc_access_control_point, &mut self.nfc_access_supported_configuration, ]; characteristics } } impl Serialize for NfcAccessServiceService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/occupancy_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, occupancy_detected::OccupancyDetectedCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Occupancy Sensor service. #[derive(Debug, Default)] pub struct OccupancySensorService { /// Instance ID of the Occupancy Sensor service. id: u64, /// [`HapType`](HapType) of the Occupancy Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Occupancy Detected characteristic (required). pub occupancy_detected: OccupancyDetectedCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl OccupancySensorService { /// Creates a new Occupancy Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::OccupancySensor, occupancy_detected: OccupancyDetectedCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 1 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for OccupancySensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.occupancy_detected, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.occupancy_detected, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for OccupancySensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/outlet.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, power_state::PowerStateCharacteristic, name::NameCharacteristic, outlet_in_use::OutletInUseCharacteristic, }, HapType, }; /// Outlet service. #[derive(Debug, Default)] pub struct OutletService { /// Instance ID of the Outlet service. id: u64, /// [`HapType`](HapType) of the Outlet service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Power State characteristic (required). pub power_state: PowerStateCharacteristic, /// Name characteristic (optional). pub name: Option, /// Outlet In Use characteristic (optional). pub outlet_in_use: Option, } impl OutletService { /// Creates a new Outlet service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Outlet, power_state: PowerStateCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), outlet_in_use: Some(OutletInUseCharacteristic::new(id + 1 + 1 + 1, accessory_id)), ..Default::default() } } } impl HapService for OutletService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.power_state, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.outlet_in_use { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.power_state, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.outlet_in_use { characteristics.push(c); } characteristics } } impl Serialize for OutletService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/pairing.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, list_pairings::ListPairingsCharacteristic, pair_setup::PairSetupCharacteristic, pair_verify::PairVerifyCharacteristic, pairing_features::PairingFeaturesCharacteristic, }, HapType, }; /// Pairing service. #[derive(Debug, Default)] pub struct PairingService { /// Instance ID of the Pairing service. id: u64, /// [`HapType`](HapType) of the Pairing service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// List Pairings characteristic (required). pub list_pairings: ListPairingsCharacteristic, /// Pair Setup characteristic (required). pub pair_setup: PairSetupCharacteristic, /// Pair Verify characteristic (required). pub pair_verify: PairVerifyCharacteristic, /// Pairing Features characteristic (required). pub pairing_features: PairingFeaturesCharacteristic, } impl PairingService { /// Creates a new Pairing service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Pairing, list_pairings: ListPairingsCharacteristic::new(id + 1 + 0, accessory_id), pair_setup: PairSetupCharacteristic::new(id + 1 + 1, accessory_id), pair_verify: PairVerifyCharacteristic::new(id + 1 + 2, accessory_id), pairing_features: PairingFeaturesCharacteristic::new(id + 1 + 3, accessory_id), ..Default::default() } } } impl HapService for PairingService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.list_pairings, &self.pair_setup, &self.pair_verify, &self.pairing_features, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.list_pairings, &mut self.pair_setup, &mut self.pair_verify, &mut self.pairing_features, ]; characteristics } } impl Serialize for PairingService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/power_management.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, wake_configuration::WakeConfigurationCharacteristic, }, HapType, }; /// Power Management service. #[derive(Debug, Default)] pub struct PowerManagementService { /// Instance ID of the Power Management service. id: u64, /// [`HapType`](HapType) of the Power Management service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Wake Configuration characteristic (required). pub wake_configuration: WakeConfigurationCharacteristic, } impl PowerManagementService { /// Creates a new Power Management service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::PowerManagement, wake_configuration: WakeConfigurationCharacteristic::new(id + 1 + 0, accessory_id), ..Default::default() } } } impl HapService for PowerManagementService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.wake_configuration, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.wake_configuration, ]; characteristics } } impl Serialize for PowerManagementService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/protocol_information.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, version::VersionCharacteristic, }, HapType, }; /// Protocol Information service. #[derive(Debug, Default)] pub struct ProtocolInformationService { /// Instance ID of the Protocol Information service. id: u64, /// [`HapType`](HapType) of the Protocol Information service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Version characteristic (required). pub version: VersionCharacteristic, } impl ProtocolInformationService { /// Creates a new Protocol Information service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::ProtocolInformation, version: VersionCharacteristic::new(id + 1 + 0, accessory_id), ..Default::default() } } } impl HapService for ProtocolInformationService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.version, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.version, ]; characteristics } } impl Serialize for ProtocolInformationService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/security_system.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, security_system_current_state::SecuritySystemCurrentStateCharacteristic, security_system_target_state::SecuritySystemTargetStateCharacteristic, name::NameCharacteristic, security_system_alarm_type::SecuritySystemAlarmTypeCharacteristic, status_fault::StatusFaultCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Security System service. #[derive(Debug, Default)] pub struct SecuritySystemService { /// Instance ID of the Security System service. id: u64, /// [`HapType`](HapType) of the Security System service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Security System Current State characteristic (required). pub security_system_current_state: SecuritySystemCurrentStateCharacteristic, /// Security System Target State characteristic (required). pub security_system_target_state: SecuritySystemTargetStateCharacteristic, /// Name characteristic (optional). pub name: Option, /// Security System Alarm Type characteristic (optional). pub security_system_alarm_type: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl SecuritySystemService { /// Creates a new Security System service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::SecuritySystem, security_system_current_state: SecuritySystemCurrentStateCharacteristic::new(id + 1 + 0, accessory_id), security_system_target_state: SecuritySystemTargetStateCharacteristic::new(id + 1 + 1, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 2, accessory_id)), security_system_alarm_type: Some(SecuritySystemAlarmTypeCharacteristic::new(id + 1 + 1 + 2, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 2, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 3 + 2, accessory_id)), ..Default::default() } } } impl HapService for SecuritySystemService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.security_system_current_state, &self.security_system_target_state, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.security_system_alarm_type { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.security_system_current_state, &mut self.security_system_target_state, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.security_system_alarm_type { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for SecuritySystemService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/siri.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, siri_input_type::SiriInputTypeCharacteristic, multifunction_button::MultifunctionButtonCharacteristic, siri_enable::SiriEnableCharacteristic, siri_engine_version::SiriEngineVersionCharacteristic, siri_light_on_use::SiriLightOnUseCharacteristic, siri_listening::SiriListeningCharacteristic, siri_touch_to_use::SiriTouchToUseCharacteristic, }, HapType, }; /// Siri service. #[derive(Debug, Default)] pub struct SiriService { /// Instance ID of the Siri service. id: u64, /// [`HapType`](HapType) of the Siri service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Siri Input Type characteristic (required). pub siri_input_type: SiriInputTypeCharacteristic, /// Multifunction Button characteristic (optional). pub multifunction_button: Option, /// Siri Enable characteristic (optional). pub siri_enable: Option, /// Siri Engine Version characteristic (optional). pub siri_engine_version: Option, /// Siri Light On Use characteristic (optional). pub siri_light_on_use: Option, /// Siri Listening characteristic (optional). pub siri_listening: Option, /// Siri Touch To Use characteristic (optional). pub siri_touch_to_use: Option, } impl SiriService { /// Creates a new Siri service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Siri, siri_input_type: SiriInputTypeCharacteristic::new(id + 1 + 0, accessory_id), multifunction_button: Some(MultifunctionButtonCharacteristic::new(id + 1 + 0 + 1, accessory_id)), siri_enable: Some(SiriEnableCharacteristic::new(id + 1 + 1 + 1, accessory_id)), siri_engine_version: Some(SiriEngineVersionCharacteristic::new(id + 1 + 2 + 1, accessory_id)), siri_light_on_use: Some(SiriLightOnUseCharacteristic::new(id + 1 + 3 + 1, accessory_id)), siri_listening: Some(SiriListeningCharacteristic::new(id + 1 + 4 + 1, accessory_id)), siri_touch_to_use: Some(SiriTouchToUseCharacteristic::new(id + 1 + 5 + 1, accessory_id)), ..Default::default() } } } impl HapService for SiriService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.siri_input_type, ]; if let Some(c) = &self.multifunction_button { characteristics.push(c); } if let Some(c) = &self.siri_enable { characteristics.push(c); } if let Some(c) = &self.siri_engine_version { characteristics.push(c); } if let Some(c) = &self.siri_light_on_use { characteristics.push(c); } if let Some(c) = &self.siri_listening { characteristics.push(c); } if let Some(c) = &self.siri_touch_to_use { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.siri_input_type, ]; if let Some(c) = &mut self.multifunction_button { characteristics.push(c); } if let Some(c) = &mut self.siri_enable { characteristics.push(c); } if let Some(c) = &mut self.siri_engine_version { characteristics.push(c); } if let Some(c) = &mut self.siri_light_on_use { characteristics.push(c); } if let Some(c) = &mut self.siri_listening { characteristics.push(c); } if let Some(c) = &mut self.siri_touch_to_use { characteristics.push(c); } characteristics } } impl Serialize for SiriService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/siri_endpoint.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, siri_endpoint_session_status::SiriEndpointSessionStatusCharacteristic, version::VersionCharacteristic, active_identifier::ActiveIdentifierCharacteristic, manually_disabled::ManuallyDisabledCharacteristic, }, HapType, }; /// Siri Endpoint service. #[derive(Debug, Default)] pub struct SiriEndpointService { /// Instance ID of the Siri Endpoint service. id: u64, /// [`HapType`](HapType) of the Siri Endpoint service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Siri Endpoint Session Status characteristic (required). pub siri_endpoint_session_status: SiriEndpointSessionStatusCharacteristic, /// Version characteristic (required). pub version: VersionCharacteristic, /// Active Identifier characteristic (optional). pub active_identifier: Option, /// Manually disabled characteristic (optional). pub manually_disabled: Option, } impl SiriEndpointService { /// Creates a new Siri Endpoint service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::SiriEndpoint, siri_endpoint_session_status: SiriEndpointSessionStatusCharacteristic::new(id + 1 + 0, accessory_id), version: VersionCharacteristic::new(id + 1 + 1, accessory_id), active_identifier: Some(ActiveIdentifierCharacteristic::new(id + 1 + 0 + 2, accessory_id)), manually_disabled: Some(ManuallyDisabledCharacteristic::new(id + 1 + 1 + 2, accessory_id)), ..Default::default() } } } impl HapService for SiriEndpointService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.siri_endpoint_session_status, &self.version, ]; if let Some(c) = &self.active_identifier { characteristics.push(c); } if let Some(c) = &self.manually_disabled { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.siri_endpoint_session_status, &mut self.version, ]; if let Some(c) = &mut self.active_identifier { characteristics.push(c); } if let Some(c) = &mut self.manually_disabled { characteristics.push(c); } characteristics } } impl Serialize for SiriEndpointService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/slats.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_slat_state::CurrentSlatStateCharacteristic, slat_type::SlatTypeCharacteristic, name::NameCharacteristic, swing_mode::SwingModeCharacteristic, current_tilt_angle::CurrentTiltAngleCharacteristic, target_tilt_angle::TargetTiltAngleCharacteristic, }, HapType, }; /// Slats service. #[derive(Debug, Default)] pub struct SlatsService { /// Instance ID of the Slats service. id: u64, /// [`HapType`](HapType) of the Slats service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Slat State characteristic (required). pub current_slat_state: CurrentSlatStateCharacteristic, /// Slat Type characteristic (required). pub slat_type: SlatTypeCharacteristic, /// Name characteristic (optional). pub name: Option, /// Swing Mode characteristic (optional). pub swing_mode: Option, /// Current Tilt Angle characteristic (optional). pub current_tilt_angle: Option, /// Target Tilt Angle characteristic (optional). pub target_tilt_angle: Option, } impl SlatsService { /// Creates a new Slats service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Slats, current_slat_state: CurrentSlatStateCharacteristic::new(id + 1 + 0, accessory_id), slat_type: SlatTypeCharacteristic::new(id + 1 + 1, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 2, accessory_id)), swing_mode: Some(SwingModeCharacteristic::new(id + 1 + 1 + 2, accessory_id)), current_tilt_angle: Some(CurrentTiltAngleCharacteristic::new(id + 1 + 2 + 2, accessory_id)), target_tilt_angle: Some(TargetTiltAngleCharacteristic::new(id + 1 + 3 + 2, accessory_id)), ..Default::default() } } } impl HapService for SlatsService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_slat_state, &self.slat_type, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.swing_mode { characteristics.push(c); } if let Some(c) = &self.current_tilt_angle { characteristics.push(c); } if let Some(c) = &self.target_tilt_angle { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_slat_state, &mut self.slat_type, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.swing_mode { characteristics.push(c); } if let Some(c) = &mut self.current_tilt_angle { characteristics.push(c); } if let Some(c) = &mut self.target_tilt_angle { characteristics.push(c); } characteristics } } impl Serialize for SlatsService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/smart_speaker.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_media_state::CurrentMediaStateCharacteristic, target_media_state::TargetMediaStateCharacteristic, airplay_enable::AirplayEnableCharacteristic, configured_name::ConfiguredNameCharacteristic, mute::MuteCharacteristic, name::NameCharacteristic, volume::VolumeCharacteristic, }, HapType, }; /// Smart Speaker service. #[derive(Debug, Default)] pub struct SmartSpeakerService { /// Instance ID of the Smart Speaker service. id: u64, /// [`HapType`](HapType) of the Smart Speaker service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Media State characteristic (required). pub current_media_state: CurrentMediaStateCharacteristic, /// Target Media State characteristic (required). pub target_media_state: TargetMediaStateCharacteristic, /// AirPlay Enable characteristic (optional). pub airplay_enable: Option, /// Configured Name characteristic (optional). pub configured_name: Option, /// Mute characteristic (optional). pub mute: Option, /// Name characteristic (optional). pub name: Option, /// Volume characteristic (optional). pub volume: Option, } impl SmartSpeakerService { /// Creates a new Smart Speaker service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::SmartSpeaker, current_media_state: CurrentMediaStateCharacteristic::new(id + 1 + 0, accessory_id), target_media_state: TargetMediaStateCharacteristic::new(id + 1 + 1, accessory_id), airplay_enable: Some(AirplayEnableCharacteristic::new(id + 1 + 0 + 2, accessory_id)), configured_name: Some(ConfiguredNameCharacteristic::new(id + 1 + 1 + 2, accessory_id)), mute: Some(MuteCharacteristic::new(id + 1 + 2 + 2, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 3 + 2, accessory_id)), volume: Some(VolumeCharacteristic::new(id + 1 + 4 + 2, accessory_id)), ..Default::default() } } } impl HapService for SmartSpeakerService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_media_state, &self.target_media_state, ]; if let Some(c) = &self.airplay_enable { characteristics.push(c); } if let Some(c) = &self.configured_name { characteristics.push(c); } if let Some(c) = &self.mute { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.volume { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_media_state, &mut self.target_media_state, ]; if let Some(c) = &mut self.airplay_enable { characteristics.push(c); } if let Some(c) = &mut self.configured_name { characteristics.push(c); } if let Some(c) = &mut self.mute { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.volume { characteristics.push(c); } characteristics } } impl Serialize for SmartSpeakerService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/smoke_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, smoke_detected::SmokeDetectedCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Smoke Sensor service. #[derive(Debug, Default)] pub struct SmokeSensorService { /// Instance ID of the Smoke Sensor service. id: u64, /// [`HapType`](HapType) of the Smoke Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Smoke Detected characteristic (required). pub smoke_detected: SmokeDetectedCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl SmokeSensorService { /// Creates a new Smoke Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::SmokeSensor, smoke_detected: SmokeDetectedCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 1 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for SmokeSensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.smoke_detected, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.smoke_detected, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for SmokeSensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/speaker.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, mute::MuteCharacteristic, active::ActiveCharacteristic, volume::VolumeCharacteristic, volume_control_type::VolumeControlTypeCharacteristic, volume_selector::VolumeSelectorCharacteristic, }, HapType, }; /// Speaker service. #[derive(Debug, Default)] pub struct SpeakerService { /// Instance ID of the Speaker service. id: u64, /// [`HapType`](HapType) of the Speaker service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Mute characteristic (required). pub mute: MuteCharacteristic, /// Active characteristic (optional). pub active: Option, /// Volume characteristic (optional). pub volume: Option, /// Volume Control Type characteristic (optional). pub volume_control_type: Option, /// Volume Selector characteristic (optional). pub volume_selector: Option, } impl SpeakerService { /// Creates a new Speaker service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Speaker, mute: MuteCharacteristic::new(id + 1 + 0, accessory_id), active: Some(ActiveCharacteristic::new(id + 1 + 0 + 1, accessory_id)), volume: Some(VolumeCharacteristic::new(id + 1 + 1 + 1, accessory_id)), volume_control_type: Some(VolumeControlTypeCharacteristic::new(id + 1 + 2 + 1, accessory_id)), volume_selector: Some(VolumeSelectorCharacteristic::new(id + 1 + 3 + 1, accessory_id)), ..Default::default() } } } impl HapService for SpeakerService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.mute, ]; if let Some(c) = &self.active { characteristics.push(c); } if let Some(c) = &self.volume { characteristics.push(c); } if let Some(c) = &self.volume_control_type { characteristics.push(c); } if let Some(c) = &self.volume_selector { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.mute, ]; if let Some(c) = &mut self.active { characteristics.push(c); } if let Some(c) = &mut self.volume { characteristics.push(c); } if let Some(c) = &mut self.volume_control_type { characteristics.push(c); } if let Some(c) = &mut self.volume_selector { characteristics.push(c); } characteristics } } impl Serialize for SpeakerService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/stateful_programmable_switch.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, programmable_switch_event::ProgrammableSwitchEventCharacteristic, programmable_switch_output_state::ProgrammableSwitchOutputStateCharacteristic, name::NameCharacteristic, }, HapType, }; /// Stateful Programmable Switch service. #[derive(Debug, Default)] pub struct StatefulProgrammableSwitchService { /// Instance ID of the Stateful Programmable Switch service. id: u64, /// [`HapType`](HapType) of the Stateful Programmable Switch service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Programmable Switch Event characteristic (required). pub programmable_switch_event: ProgrammableSwitchEventCharacteristic, /// Programmable Switch Output State characteristic (required). pub programmable_switch_output_state: ProgrammableSwitchOutputStateCharacteristic, /// Name characteristic (optional). pub name: Option, } impl StatefulProgrammableSwitchService { /// Creates a new Stateful Programmable Switch service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::StatefulProgrammableSwitch, programmable_switch_event: ProgrammableSwitchEventCharacteristic::new(id + 1 + 0, accessory_id), programmable_switch_output_state: ProgrammableSwitchOutputStateCharacteristic::new(id + 1 + 1, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 2, accessory_id)), ..Default::default() } } } impl HapService for StatefulProgrammableSwitchService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.programmable_switch_event, &self.programmable_switch_output_state, ]; if let Some(c) = &self.name { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.programmable_switch_event, &mut self.programmable_switch_output_state, ]; if let Some(c) = &mut self.name { characteristics.push(c); } characteristics } } impl Serialize for StatefulProgrammableSwitchService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/stateless_programmable_switch.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, programmable_switch_event::ProgrammableSwitchEventCharacteristic, name::NameCharacteristic, label_index::LabelIndexCharacteristic, }, HapType, }; /// Stateless Programmable Switch service. #[derive(Debug, Default)] pub struct StatelessProgrammableSwitchService { /// Instance ID of the Stateless Programmable Switch service. id: u64, /// [`HapType`](HapType) of the Stateless Programmable Switch service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Programmable Switch Event characteristic (required). pub programmable_switch_event: ProgrammableSwitchEventCharacteristic, /// Name characteristic (optional). pub name: Option, /// Label Index characteristic (optional). pub label_index: Option, } impl StatelessProgrammableSwitchService { /// Creates a new Stateless Programmable Switch service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::StatelessProgrammableSwitch, programmable_switch_event: ProgrammableSwitchEventCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), label_index: Some(LabelIndexCharacteristic::new(id + 1 + 1 + 1, accessory_id)), ..Default::default() } } } impl HapService for StatelessProgrammableSwitchService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.programmable_switch_event, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.label_index { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.programmable_switch_event, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.label_index { characteristics.push(c); } characteristics } } impl Serialize for StatelessProgrammableSwitchService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/switch.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, power_state::PowerStateCharacteristic, name::NameCharacteristic, }, HapType, }; /// Switch service. #[derive(Debug, Default)] pub struct SwitchService { /// Instance ID of the Switch service. id: u64, /// [`HapType`](HapType) of the Switch service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Power State characteristic (required). pub power_state: PowerStateCharacteristic, /// Name characteristic (optional). pub name: Option, } impl SwitchService { /// Creates a new Switch service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Switch, power_state: PowerStateCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), ..Default::default() } } } impl HapService for SwitchService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.power_state, ]; if let Some(c) = &self.name { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.power_state, ]; if let Some(c) = &mut self.name { characteristics.push(c); } characteristics } } impl Serialize for SwitchService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/target_control.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, active_identifier::ActiveIdentifierCharacteristic, button_event::ButtonEventCharacteristic, name::NameCharacteristic, }, HapType, }; /// Target Control service. #[derive(Debug, Default)] pub struct TargetControlService { /// Instance ID of the Target Control service. id: u64, /// [`HapType`](HapType) of the Target Control service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Active Identifier characteristic (required). pub active_identifier: ActiveIdentifierCharacteristic, /// Button Event characteristic (required). pub button_event: ButtonEventCharacteristic, /// Name characteristic (optional). pub name: Option, } impl TargetControlService { /// Creates a new Target Control service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::TargetControl, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), active_identifier: ActiveIdentifierCharacteristic::new(id + 1 + 1, accessory_id), button_event: ButtonEventCharacteristic::new(id + 1 + 2, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 3, accessory_id)), ..Default::default() } } } impl HapService for TargetControlService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.active_identifier, &self.button_event, ]; if let Some(c) = &self.name { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.active_identifier, &mut self.button_event, ]; if let Some(c) = &mut self.name { characteristics.push(c); } characteristics } } impl Serialize for TargetControlService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/target_control_management.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, supported_target_configuration::SupportedTargetConfigurationCharacteristic, target_list_configuration::TargetListConfigurationCharacteristic, }, HapType, }; /// Target Control Management service. #[derive(Debug, Default)] pub struct TargetControlManagementService { /// Instance ID of the Target Control Management service. id: u64, /// [`HapType`](HapType) of the Target Control Management service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Supported Target Configuration characteristic (required). pub supported_target_configuration: SupportedTargetConfigurationCharacteristic, /// Target List Configuration characteristic (required). pub target_list_configuration: TargetListConfigurationCharacteristic, } impl TargetControlManagementService { /// Creates a new Target Control Management service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::TargetControlManagement, supported_target_configuration: SupportedTargetConfigurationCharacteristic::new(id + 1 + 0, accessory_id), target_list_configuration: TargetListConfigurationCharacteristic::new(id + 1 + 1, accessory_id), ..Default::default() } } } impl HapService for TargetControlManagementService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.supported_target_configuration, &self.target_list_configuration, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.supported_target_configuration, &mut self.target_list_configuration, ]; characteristics } } impl Serialize for TargetControlManagementService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/television.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, active_identifier::ActiveIdentifierCharacteristic, configured_name::ConfiguredNameCharacteristic, remote_key::RemoteKeyCharacteristic, sleep_discovery_mode::SleepDiscoveryModeCharacteristic, brightness::BrightnessCharacteristic, closed_captions::ClosedCaptionsCharacteristic, display_order::DisplayOrderCharacteristic, current_media_state::CurrentMediaStateCharacteristic, target_media_state::TargetMediaStateCharacteristic, name::NameCharacteristic, picture_mode::PictureModeCharacteristic, power_mode_selection::PowerModeSelectionCharacteristic, }, HapType, }; /// Television service. #[derive(Debug, Default)] pub struct TelevisionService { /// Instance ID of the Television service. id: u64, /// [`HapType`](HapType) of the Television service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// Active Identifier characteristic (required). pub active_identifier: ActiveIdentifierCharacteristic, /// Configured Name characteristic (required). pub configured_name: ConfiguredNameCharacteristic, /// Remote Key characteristic (required). pub remote_key: RemoteKeyCharacteristic, /// Sleep Discovery Mode characteristic (required). pub sleep_discovery_mode: SleepDiscoveryModeCharacteristic, /// Brightness characteristic (optional). pub brightness: Option, /// Closed Captions characteristic (optional). pub closed_captions: Option, /// Display Order characteristic (optional). pub display_order: Option, /// Current Media State characteristic (optional). pub current_media_state: Option, /// Target Media State characteristic (optional). pub target_media_state: Option, /// Name characteristic (optional). pub name: Option, /// Picture Mode characteristic (optional). pub picture_mode: Option, /// Power Mode Selection characteristic (optional). pub power_mode_selection: Option, } impl TelevisionService { /// Creates a new Television service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Television, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), active_identifier: ActiveIdentifierCharacteristic::new(id + 1 + 1, accessory_id), configured_name: ConfiguredNameCharacteristic::new(id + 1 + 2, accessory_id), remote_key: RemoteKeyCharacteristic::new(id + 1 + 3, accessory_id), sleep_discovery_mode: SleepDiscoveryModeCharacteristic::new(id + 1 + 4, accessory_id), brightness: Some(BrightnessCharacteristic::new(id + 1 + 0 + 5, accessory_id)), closed_captions: Some(ClosedCaptionsCharacteristic::new(id + 1 + 1 + 5, accessory_id)), display_order: Some(DisplayOrderCharacteristic::new(id + 1 + 2 + 5, accessory_id)), current_media_state: Some(CurrentMediaStateCharacteristic::new(id + 1 + 3 + 5, accessory_id)), target_media_state: Some(TargetMediaStateCharacteristic::new(id + 1 + 4 + 5, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 5 + 5, accessory_id)), picture_mode: Some(PictureModeCharacteristic::new(id + 1 + 6 + 5, accessory_id)), power_mode_selection: Some(PowerModeSelectionCharacteristic::new(id + 1 + 7 + 5, accessory_id)), ..Default::default() } } } impl HapService for TelevisionService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.active_identifier, &self.configured_name, &self.remote_key, &self.sleep_discovery_mode, ]; if let Some(c) = &self.brightness { characteristics.push(c); } if let Some(c) = &self.closed_captions { characteristics.push(c); } if let Some(c) = &self.display_order { characteristics.push(c); } if let Some(c) = &self.current_media_state { characteristics.push(c); } if let Some(c) = &self.target_media_state { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.picture_mode { characteristics.push(c); } if let Some(c) = &self.power_mode_selection { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.active_identifier, &mut self.configured_name, &mut self.remote_key, &mut self.sleep_discovery_mode, ]; if let Some(c) = &mut self.brightness { characteristics.push(c); } if let Some(c) = &mut self.closed_captions { characteristics.push(c); } if let Some(c) = &mut self.display_order { characteristics.push(c); } if let Some(c) = &mut self.current_media_state { characteristics.push(c); } if let Some(c) = &mut self.target_media_state { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.picture_mode { characteristics.push(c); } if let Some(c) = &mut self.power_mode_selection { characteristics.push(c); } characteristics } } impl Serialize for TelevisionService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/temperature_sensor.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_temperature::CurrentTemperatureCharacteristic, name::NameCharacteristic, status_active::StatusActiveCharacteristic, status_fault::StatusFaultCharacteristic, status_low_battery::StatusLowBatteryCharacteristic, status_tampered::StatusTamperedCharacteristic, }, HapType, }; /// Temperature Sensor service. #[derive(Debug, Default)] pub struct TemperatureSensorService { /// Instance ID of the Temperature Sensor service. id: u64, /// [`HapType`](HapType) of the Temperature Sensor service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Temperature characteristic (required). pub current_temperature: CurrentTemperatureCharacteristic, /// Name characteristic (optional). pub name: Option, /// Status Active characteristic (optional). pub status_active: Option, /// Status Fault characteristic (optional). pub status_fault: Option, /// Status Low Battery characteristic (optional). pub status_low_battery: Option, /// Status Tampered characteristic (optional). pub status_tampered: Option, } impl TemperatureSensorService { /// Creates a new Temperature Sensor service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::TemperatureSensor, current_temperature: CurrentTemperatureCharacteristic::new(id + 1 + 0, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 1, accessory_id)), status_active: Some(StatusActiveCharacteristic::new(id + 1 + 1 + 1, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 2 + 1, accessory_id)), status_low_battery: Some(StatusLowBatteryCharacteristic::new(id + 1 + 3 + 1, accessory_id)), status_tampered: Some(StatusTamperedCharacteristic::new(id + 1 + 4 + 1, accessory_id)), ..Default::default() } } } impl HapService for TemperatureSensorService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_temperature, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.status_active { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } if let Some(c) = &self.status_low_battery { characteristics.push(c); } if let Some(c) = &self.status_tampered { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_temperature, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.status_active { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } if let Some(c) = &mut self.status_low_battery { characteristics.push(c); } if let Some(c) = &mut self.status_tampered { characteristics.push(c); } characteristics } } impl Serialize for TemperatureSensorService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/thermostat.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_heating_cooling_state::CurrentHeatingCoolingStateCharacteristic, target_heating_cooling_state::TargetHeatingCoolingStateCharacteristic, current_temperature::CurrentTemperatureCharacteristic, target_temperature::TargetTemperatureCharacteristic, temperature_display_units::TemperatureDisplayUnitsCharacteristic, name::NameCharacteristic, current_relative_humidity::CurrentRelativeHumidityCharacteristic, target_relative_humidity::TargetRelativeHumidityCharacteristic, cooling_threshold_temperature::CoolingThresholdTemperatureCharacteristic, heating_threshold_temperature::HeatingThresholdTemperatureCharacteristic, }, HapType, }; /// Thermostat service. #[derive(Debug, Default)] pub struct ThermostatService { /// Instance ID of the Thermostat service. id: u64, /// [`HapType`](HapType) of the Thermostat service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Heating Cooling State characteristic (required). pub current_heating_cooling_state: CurrentHeatingCoolingStateCharacteristic, /// Target Heating Cooling State characteristic (required). pub target_heating_cooling_state: TargetHeatingCoolingStateCharacteristic, /// Current Temperature characteristic (required). pub current_temperature: CurrentTemperatureCharacteristic, /// Target Temperature characteristic (required). pub target_temperature: TargetTemperatureCharacteristic, /// Temperature Display Units characteristic (required). pub temperature_display_units: TemperatureDisplayUnitsCharacteristic, /// Name characteristic (optional). pub name: Option, /// Current Relative Humidity characteristic (optional). pub current_relative_humidity: Option, /// Target Relative Humidity characteristic (optional). pub target_relative_humidity: Option, /// Cooling Threshold Temperature characteristic (optional). pub cooling_threshold_temperature: Option, /// Heating Threshold Temperature characteristic (optional). pub heating_threshold_temperature: Option, } impl ThermostatService { /// Creates a new Thermostat service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Thermostat, current_heating_cooling_state: CurrentHeatingCoolingStateCharacteristic::new(id + 1 + 0, accessory_id), target_heating_cooling_state: TargetHeatingCoolingStateCharacteristic::new(id + 1 + 1, accessory_id), current_temperature: CurrentTemperatureCharacteristic::new(id + 1 + 2, accessory_id), target_temperature: TargetTemperatureCharacteristic::new(id + 1 + 3, accessory_id), temperature_display_units: TemperatureDisplayUnitsCharacteristic::new(id + 1 + 4, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 5, accessory_id)), current_relative_humidity: Some(CurrentRelativeHumidityCharacteristic::new(id + 1 + 1 + 5, accessory_id)), target_relative_humidity: Some(TargetRelativeHumidityCharacteristic::new(id + 1 + 2 + 5, accessory_id)), cooling_threshold_temperature: Some(CoolingThresholdTemperatureCharacteristic::new(id + 1 + 3 + 5, accessory_id)), heating_threshold_temperature: Some(HeatingThresholdTemperatureCharacteristic::new(id + 1 + 4 + 5, accessory_id)), ..Default::default() } } } impl HapService for ThermostatService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_heating_cooling_state, &self.target_heating_cooling_state, &self.current_temperature, &self.target_temperature, &self.temperature_display_units, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.current_relative_humidity { characteristics.push(c); } if let Some(c) = &self.target_relative_humidity { characteristics.push(c); } if let Some(c) = &self.cooling_threshold_temperature { characteristics.push(c); } if let Some(c) = &self.heating_threshold_temperature { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_heating_cooling_state, &mut self.target_heating_cooling_state, &mut self.current_temperature, &mut self.target_temperature, &mut self.temperature_display_units, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.current_relative_humidity { characteristics.push(c); } if let Some(c) = &mut self.target_relative_humidity { characteristics.push(c); } if let Some(c) = &mut self.cooling_threshold_temperature { characteristics.push(c); } if let Some(c) = &mut self.heating_threshold_temperature { characteristics.push(c); } characteristics } } impl Serialize for ThermostatService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/thread_transport.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_transport::CurrentTransportCharacteristic, thread_control_point::ThreadControlPointCharacteristic, thread_node_capabilities::ThreadNodeCapabilitiesCharacteristic, thread_status::ThreadStatusCharacteristic, cca_energy_detect_threshold::CcaEnergyDetectThresholdCharacteristic, cca_signal_detect_threshold::CcaSignalDetectThresholdCharacteristic, event_retransmission_maximum::EventRetransmissionMaximumCharacteristic, event_transmission_counters::EventTransmissionCountersCharacteristic, mac_retransmission_maximum::MacRetransmissionMaximumCharacteristic, mac_transmission_counters::MacTransmissionCountersCharacteristic, receiver_sensitivity::ReceiverSensitivityCharacteristic, received_signal_strength_indication::ReceivedSignalStrengthIndicationCharacteristic, signal_to_noise_ratio::SignalToNoiseRatioCharacteristic, thread_openthread_version::ThreadOpenthreadVersionCharacteristic, transmit_power::TransmitPowerCharacteristic, maximum_transmit_power::MaximumTransmitPowerCharacteristic, }, HapType, }; /// Thread Transport service. #[derive(Debug, Default)] pub struct ThreadTransportService { /// Instance ID of the Thread Transport service. id: u64, /// [`HapType`](HapType) of the Thread Transport service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Transport characteristic (required). pub current_transport: CurrentTransportCharacteristic, /// Thread Control Point characteristic (required). pub thread_control_point: ThreadControlPointCharacteristic, /// Thread Node Capabilities characteristic (required). pub thread_node_capabilities: ThreadNodeCapabilitiesCharacteristic, /// Thread Status characteristic (required). pub thread_status: ThreadStatusCharacteristic, /// CCA Energy Detect Threshold characteristic (optional). pub cca_energy_detect_threshold: Option, /// CCA Signal Detect Threshold characteristic (optional). pub cca_signal_detect_threshold: Option, /// Event Retransmission Maximum characteristic (optional). pub event_retransmission_maximum: Option, /// Event Transmission Counters characteristic (optional). pub event_transmission_counters: Option, /// MAC Retransmission Maximum characteristic (optional). pub mac_retransmission_maximum: Option, /// MAC Transmission Counters characteristic (optional). pub mac_transmission_counters: Option, /// Receiver Sensitivity characteristic (optional). pub receiver_sensitivity: Option, /// Received Signal Strength Indication characteristic (optional). pub received_signal_strength_indication: Option, /// Signal-to-noise Ratio characteristic (optional). pub signal_to_noise_ratio: Option, /// Thread OpenThread Version characteristic (optional). pub thread_openthread_version: Option, /// Transmit Power characteristic (optional). pub transmit_power: Option, /// Maximum Transmit Power characteristic (optional). pub maximum_transmit_power: Option, } impl ThreadTransportService { /// Creates a new Thread Transport service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::ThreadTransport, current_transport: CurrentTransportCharacteristic::new(id + 1 + 0, accessory_id), thread_control_point: ThreadControlPointCharacteristic::new(id + 1 + 1, accessory_id), thread_node_capabilities: ThreadNodeCapabilitiesCharacteristic::new(id + 1 + 2, accessory_id), thread_status: ThreadStatusCharacteristic::new(id + 1 + 3, accessory_id), cca_energy_detect_threshold: Some(CcaEnergyDetectThresholdCharacteristic::new(id + 1 + 0 + 4, accessory_id)), cca_signal_detect_threshold: Some(CcaSignalDetectThresholdCharacteristic::new(id + 1 + 1 + 4, accessory_id)), event_retransmission_maximum: Some(EventRetransmissionMaximumCharacteristic::new(id + 1 + 2 + 4, accessory_id)), event_transmission_counters: Some(EventTransmissionCountersCharacteristic::new(id + 1 + 3 + 4, accessory_id)), mac_retransmission_maximum: Some(MacRetransmissionMaximumCharacteristic::new(id + 1 + 4 + 4, accessory_id)), mac_transmission_counters: Some(MacTransmissionCountersCharacteristic::new(id + 1 + 5 + 4, accessory_id)), receiver_sensitivity: Some(ReceiverSensitivityCharacteristic::new(id + 1 + 6 + 4, accessory_id)), received_signal_strength_indication: Some(ReceivedSignalStrengthIndicationCharacteristic::new(id + 1 + 7 + 4, accessory_id)), signal_to_noise_ratio: Some(SignalToNoiseRatioCharacteristic::new(id + 1 + 8 + 4, accessory_id)), thread_openthread_version: Some(ThreadOpenthreadVersionCharacteristic::new(id + 1 + 9 + 4, accessory_id)), transmit_power: Some(TransmitPowerCharacteristic::new(id + 1 + 10 + 4, accessory_id)), maximum_transmit_power: Some(MaximumTransmitPowerCharacteristic::new(id + 1 + 11 + 4, accessory_id)), ..Default::default() } } } impl HapService for ThreadTransportService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_transport, &self.thread_control_point, &self.thread_node_capabilities, &self.thread_status, ]; if let Some(c) = &self.cca_energy_detect_threshold { characteristics.push(c); } if let Some(c) = &self.cca_signal_detect_threshold { characteristics.push(c); } if let Some(c) = &self.event_retransmission_maximum { characteristics.push(c); } if let Some(c) = &self.event_transmission_counters { characteristics.push(c); } if let Some(c) = &self.mac_retransmission_maximum { characteristics.push(c); } if let Some(c) = &self.mac_transmission_counters { characteristics.push(c); } if let Some(c) = &self.receiver_sensitivity { characteristics.push(c); } if let Some(c) = &self.received_signal_strength_indication { characteristics.push(c); } if let Some(c) = &self.signal_to_noise_ratio { characteristics.push(c); } if let Some(c) = &self.thread_openthread_version { characteristics.push(c); } if let Some(c) = &self.transmit_power { characteristics.push(c); } if let Some(c) = &self.maximum_transmit_power { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_transport, &mut self.thread_control_point, &mut self.thread_node_capabilities, &mut self.thread_status, ]; if let Some(c) = &mut self.cca_energy_detect_threshold { characteristics.push(c); } if let Some(c) = &mut self.cca_signal_detect_threshold { characteristics.push(c); } if let Some(c) = &mut self.event_retransmission_maximum { characteristics.push(c); } if let Some(c) = &mut self.event_transmission_counters { characteristics.push(c); } if let Some(c) = &mut self.mac_retransmission_maximum { characteristics.push(c); } if let Some(c) = &mut self.mac_transmission_counters { characteristics.push(c); } if let Some(c) = &mut self.receiver_sensitivity { characteristics.push(c); } if let Some(c) = &mut self.received_signal_strength_indication { characteristics.push(c); } if let Some(c) = &mut self.signal_to_noise_ratio { characteristics.push(c); } if let Some(c) = &mut self.thread_openthread_version { characteristics.push(c); } if let Some(c) = &mut self.transmit_power { characteristics.push(c); } if let Some(c) = &mut self.maximum_transmit_power { characteristics.push(c); } characteristics } } impl Serialize for ThreadTransportService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/transfer_transport_management.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, supported_transfer_transport_configuration::SupportedTransferTransportConfigurationCharacteristic, setup_transfer_transport::SetupTransferTransportCharacteristic, }, HapType, }; /// Transfer Transport Management service. #[derive(Debug, Default)] pub struct TransferTransportManagementService { /// Instance ID of the Transfer Transport Management service. id: u64, /// [`HapType`](HapType) of the Transfer Transport Management service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Supported Transfer Transport Configuration characteristic (required). pub supported_transfer_transport_configuration: SupportedTransferTransportConfigurationCharacteristic, /// Setup Transfer Transport characteristic (required). pub setup_transfer_transport: SetupTransferTransportCharacteristic, } impl TransferTransportManagementService { /// Creates a new Transfer Transport Management service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::TransferTransportManagement, supported_transfer_transport_configuration: SupportedTransferTransportConfigurationCharacteristic::new(id + 1 + 0, accessory_id), setup_transfer_transport: SetupTransferTransportCharacteristic::new(id + 1 + 1, accessory_id), ..Default::default() } } } impl HapService for TransferTransportManagementService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.supported_transfer_transport_configuration, &self.setup_transfer_transport, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.supported_transfer_transport_configuration, &mut self.setup_transfer_transport, ]; characteristics } } impl Serialize for TransferTransportManagementService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/valve.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, active::ActiveCharacteristic, in_use::InUseCharacteristic, valve_type::ValveTypeCharacteristic, is_configured::IsConfiguredCharacteristic, name::NameCharacteristic, remaining_duration::RemainingDurationCharacteristic, label_index::LabelIndexCharacteristic, set_duration::SetDurationCharacteristic, status_fault::StatusFaultCharacteristic, }, HapType, }; /// Valve service. #[derive(Debug, Default)] pub struct ValveService { /// Instance ID of the Valve service. id: u64, /// [`HapType`](HapType) of the Valve service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Active characteristic (required). pub active: ActiveCharacteristic, /// In Use characteristic (required). pub in_use: InUseCharacteristic, /// Valve Type characteristic (required). pub valve_type: ValveTypeCharacteristic, /// Is Configured characteristic (optional). pub is_configured: Option, /// Name characteristic (optional). pub name: Option, /// Remaining Duration characteristic (optional). pub remaining_duration: Option, /// Label Index characteristic (optional). pub label_index: Option, /// Set Duration characteristic (optional). pub set_duration: Option, /// Status Fault characteristic (optional). pub status_fault: Option, } impl ValveService { /// Creates a new Valve service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Valve, active: ActiveCharacteristic::new(id + 1 + 0, accessory_id), in_use: InUseCharacteristic::new(id + 1 + 1, accessory_id), valve_type: ValveTypeCharacteristic::new(id + 1 + 2, accessory_id), is_configured: Some(IsConfiguredCharacteristic::new(id + 1 + 0 + 3, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 1 + 3, accessory_id)), remaining_duration: Some(RemainingDurationCharacteristic::new(id + 1 + 2 + 3, accessory_id)), label_index: Some(LabelIndexCharacteristic::new(id + 1 + 3 + 3, accessory_id)), set_duration: Some(SetDurationCharacteristic::new(id + 1 + 4 + 3, accessory_id)), status_fault: Some(StatusFaultCharacteristic::new(id + 1 + 5 + 3, accessory_id)), ..Default::default() } } } impl HapService for ValveService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.active, &self.in_use, &self.valve_type, ]; if let Some(c) = &self.is_configured { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.remaining_duration { characteristics.push(c); } if let Some(c) = &self.label_index { characteristics.push(c); } if let Some(c) = &self.set_duration { characteristics.push(c); } if let Some(c) = &self.status_fault { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.active, &mut self.in_use, &mut self.valve_type, ]; if let Some(c) = &mut self.is_configured { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.remaining_duration { characteristics.push(c); } if let Some(c) = &mut self.label_index { characteristics.push(c); } if let Some(c) = &mut self.set_duration { characteristics.push(c); } if let Some(c) = &mut self.status_fault { characteristics.push(c); } characteristics } } impl Serialize for ValveService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/wi_fi_router.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, configured_name::ConfiguredNameCharacteristic, managed_network_enable::ManagedNetworkEnableCharacteristic, network_access_violation_control::NetworkAccessViolationControlCharacteristic, network_client_control::NetworkClientControlCharacteristic, network_client_status_control::NetworkClientStatusControlCharacteristic, router_status::RouterStatusCharacteristic, supported_router_configuration::SupportedRouterConfigurationCharacteristic, wan_configuration_list::WanConfigurationListCharacteristic, wan_status_list::WanStatusListCharacteristic, }, HapType, }; /// Wi-Fi Router service. #[derive(Debug, Default)] pub struct WiFiRouterService { /// Instance ID of the Wi-Fi Router service. id: u64, /// [`HapType`](HapType) of the Wi-Fi Router service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Configured Name characteristic (required). pub configured_name: ConfiguredNameCharacteristic, /// Managed Network Enable characteristic (required). pub managed_network_enable: ManagedNetworkEnableCharacteristic, /// Network Access Violation Control characteristic (required). pub network_access_violation_control: NetworkAccessViolationControlCharacteristic, /// Network Client Control characteristic (required). pub network_client_control: NetworkClientControlCharacteristic, /// Network Client Status Control characteristic (required). pub network_client_status_control: NetworkClientStatusControlCharacteristic, /// Router Status characteristic (required). pub router_status: RouterStatusCharacteristic, /// Supported Router Configuration characteristic (required). pub supported_router_configuration: SupportedRouterConfigurationCharacteristic, /// WAN Configuration List characteristic (required). pub wan_configuration_list: WanConfigurationListCharacteristic, /// WAN Status List characteristic (required). pub wan_status_list: WanStatusListCharacteristic, } impl WiFiRouterService { /// Creates a new Wi-Fi Router service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::WiFiRouter, configured_name: ConfiguredNameCharacteristic::new(id + 1 + 0, accessory_id), managed_network_enable: ManagedNetworkEnableCharacteristic::new(id + 1 + 1, accessory_id), network_access_violation_control: NetworkAccessViolationControlCharacteristic::new(id + 1 + 2, accessory_id), network_client_control: NetworkClientControlCharacteristic::new(id + 1 + 3, accessory_id), network_client_status_control: NetworkClientStatusControlCharacteristic::new(id + 1 + 4, accessory_id), router_status: RouterStatusCharacteristic::new(id + 1 + 5, accessory_id), supported_router_configuration: SupportedRouterConfigurationCharacteristic::new(id + 1 + 6, accessory_id), wan_configuration_list: WanConfigurationListCharacteristic::new(id + 1 + 7, accessory_id), wan_status_list: WanStatusListCharacteristic::new(id + 1 + 8, accessory_id), ..Default::default() } } } impl HapService for WiFiRouterService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.configured_name, &self.managed_network_enable, &self.network_access_violation_control, &self.network_client_control, &self.network_client_status_control, &self.router_status, &self.supported_router_configuration, &self.wan_configuration_list, &self.wan_status_list, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.configured_name, &mut self.managed_network_enable, &mut self.network_access_violation_control, &mut self.network_client_control, &mut self.network_client_status_control, &mut self.router_status, &mut self.supported_router_configuration, &mut self.wan_configuration_list, &mut self.wan_status_list, ]; characteristics } } impl Serialize for WiFiRouterService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/wi_fi_satellite.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, wi_fi_satellite_status::WiFiSatelliteStatusCharacteristic, }, HapType, }; /// Wi-Fi Satellite service. #[derive(Debug, Default)] pub struct WiFiSatelliteService { /// Instance ID of the Wi-Fi Satellite service. id: u64, /// [`HapType`](HapType) of the Wi-Fi Satellite service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Wi-Fi Satellite Status characteristic (required). pub wi_fi_satellite_status: WiFiSatelliteStatusCharacteristic, } impl WiFiSatelliteService { /// Creates a new Wi-Fi Satellite service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::WiFiSatellite, wi_fi_satellite_status: WiFiSatelliteStatusCharacteristic::new(id + 1 + 0, accessory_id), ..Default::default() } } } impl HapService for WiFiSatelliteService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.wi_fi_satellite_status, ]; characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.wi_fi_satellite_status, ]; characteristics } } impl Serialize for WiFiSatelliteService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/wi_fi_transport.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_transport::CurrentTransportCharacteristic, wi_fi_capabilities::WiFiCapabilitiesCharacteristic, wi_fi_configuration_control::WiFiConfigurationControlCharacteristic, }, HapType, }; /// Wi-Fi Transport service. #[derive(Debug, Default)] pub struct WiFiTransportService { /// Instance ID of the Wi-Fi Transport service. id: u64, /// [`HapType`](HapType) of the Wi-Fi Transport service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Transport characteristic (required). pub current_transport: CurrentTransportCharacteristic, /// Wi-Fi Capabilities characteristic (required). pub wi_fi_capabilities: WiFiCapabilitiesCharacteristic, /// Wi-Fi Configuration Control characteristic (optional). pub wi_fi_configuration_control: Option, } impl WiFiTransportService { /// Creates a new Wi-Fi Transport service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::WiFiTransport, current_transport: CurrentTransportCharacteristic::new(id + 1 + 0, accessory_id), wi_fi_capabilities: WiFiCapabilitiesCharacteristic::new(id + 1 + 1, accessory_id), wi_fi_configuration_control: Some(WiFiConfigurationControlCharacteristic::new(id + 1 + 0 + 2, accessory_id)), ..Default::default() } } } impl HapService for WiFiTransportService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_transport, &self.wi_fi_capabilities, ]; if let Some(c) = &self.wi_fi_configuration_control { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_transport, &mut self.wi_fi_capabilities, ]; if let Some(c) = &mut self.wi_fi_configuration_control { characteristics.push(c); } characteristics } } impl Serialize for WiFiTransportService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/window.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_position::CurrentPositionCharacteristic, position_state::PositionStateCharacteristic, target_position::TargetPositionCharacteristic, name::NameCharacteristic, obstruction_detected::ObstructionDetectedCharacteristic, hold_position::HoldPositionCharacteristic, }, HapType, }; /// Window service. #[derive(Debug, Default)] pub struct WindowService { /// Instance ID of the Window service. id: u64, /// [`HapType`](HapType) of the Window service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Position characteristic (required). pub current_position: CurrentPositionCharacteristic, /// Position State characteristic (required). pub position_state: PositionStateCharacteristic, /// Target Position characteristic (required). pub target_position: TargetPositionCharacteristic, /// Name characteristic (optional). pub name: Option, /// Obstruction Detected characteristic (optional). pub obstruction_detected: Option, /// Hold Position characteristic (optional). pub hold_position: Option, } impl WindowService { /// Creates a new Window service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::Window, current_position: CurrentPositionCharacteristic::new(id + 1 + 0, accessory_id), position_state: PositionStateCharacteristic::new(id + 1 + 1, accessory_id), target_position: TargetPositionCharacteristic::new(id + 1 + 2, accessory_id), name: Some(NameCharacteristic::new(id + 1 + 0 + 3, accessory_id)), obstruction_detected: Some(ObstructionDetectedCharacteristic::new(id + 1 + 1 + 3, accessory_id)), hold_position: Some(HoldPositionCharacteristic::new(id + 1 + 2 + 3, accessory_id)), ..Default::default() } } } impl HapService for WindowService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_position, &self.position_state, &self.target_position, ]; if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.obstruction_detected { characteristics.push(c); } if let Some(c) = &self.hold_position { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_position, &mut self.position_state, &mut self.target_position, ]; if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.obstruction_detected { characteristics.push(c); } if let Some(c) = &mut self.hold_position { characteristics.push(c); } characteristics } } impl Serialize for WindowService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/generated/window_covering.rs ================================================ // this file is auto-generated by hap-codegen use serde::ser::{Serialize, SerializeStruct, Serializer}; use crate::{ service::HapService, characteristic::{ HapCharacteristic, current_position::CurrentPositionCharacteristic, position_state::PositionStateCharacteristic, target_position::TargetPositionCharacteristic, current_horizontal_tilt_angle::CurrentHorizontalTiltAngleCharacteristic, target_horizontal_tilt_angle::TargetHorizontalTiltAngleCharacteristic, name::NameCharacteristic, obstruction_detected::ObstructionDetectedCharacteristic, hold_position::HoldPositionCharacteristic, current_vertical_tilt_angle::CurrentVerticalTiltAngleCharacteristic, target_vertical_tilt_angle::TargetVerticalTiltAngleCharacteristic, }, HapType, }; /// Window Covering service. #[derive(Debug, Default)] pub struct WindowCoveringService { /// Instance ID of the Window Covering service. id: u64, /// [`HapType`](HapType) of the Window Covering service. hap_type: HapType, /// When set to true, this service is not visible to user. hidden: bool, /// When set to true, this is the primary service on the accessory. primary: bool, /// An array of numbers containing the instance IDs of the services that this service links to. linked_services: Vec, /// Current Position characteristic (required). pub current_position: CurrentPositionCharacteristic, /// Position State characteristic (required). pub position_state: PositionStateCharacteristic, /// Target Position characteristic (required). pub target_position: TargetPositionCharacteristic, /// Current Horizontal Tilt Angle characteristic (optional). pub current_horizontal_tilt_angle: Option, /// Target Horizontal Tilt Angle characteristic (optional). pub target_horizontal_tilt_angle: Option, /// Name characteristic (optional). pub name: Option, /// Obstruction Detected characteristic (optional). pub obstruction_detected: Option, /// Hold Position characteristic (optional). pub hold_position: Option, /// Current Vertical Tilt Angle characteristic (optional). pub current_vertical_tilt_angle: Option, /// Target Vertical Tilt Angle characteristic (optional). pub target_vertical_tilt_angle: Option, } impl WindowCoveringService { /// Creates a new Window Covering service. pub fn new(id: u64, accessory_id: u64) -> Self { Self { id, hap_type: HapType::WindowCovering, current_position: CurrentPositionCharacteristic::new(id + 1 + 0, accessory_id), position_state: PositionStateCharacteristic::new(id + 1 + 1, accessory_id), target_position: TargetPositionCharacteristic::new(id + 1 + 2, accessory_id), current_horizontal_tilt_angle: Some(CurrentHorizontalTiltAngleCharacteristic::new(id + 1 + 0 + 3, accessory_id)), target_horizontal_tilt_angle: Some(TargetHorizontalTiltAngleCharacteristic::new(id + 1 + 1 + 3, accessory_id)), name: Some(NameCharacteristic::new(id + 1 + 2 + 3, accessory_id)), obstruction_detected: Some(ObstructionDetectedCharacteristic::new(id + 1 + 3 + 3, accessory_id)), hold_position: Some(HoldPositionCharacteristic::new(id + 1 + 4 + 3, accessory_id)), current_vertical_tilt_angle: Some(CurrentVerticalTiltAngleCharacteristic::new(id + 1 + 5 + 3, accessory_id)), target_vertical_tilt_angle: Some(TargetVerticalTiltAngleCharacteristic::new(id + 1 + 6 + 3, accessory_id)), ..Default::default() } } } impl HapService for WindowCoveringService { fn get_id(&self) -> u64 { self.id } fn set_id(&mut self, id: u64) { self.id = id; } fn get_type(&self) -> HapType { self.hap_type } fn set_type(&mut self, hap_type: HapType) { self.hap_type = hap_type; } fn get_hidden(&self) -> bool { self.hidden } fn set_hidden(&mut self, hidden: bool) { self.hidden = hidden; } fn get_primary(&self) -> bool { self.primary } fn set_primary(&mut self, primary: bool) { self.primary = primary; } fn get_linked_services(&self) -> Vec { self.linked_services.clone() } fn set_linked_services(&mut self, linked_services: Vec) { self.linked_services = linked_services; } fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic> { for characteristic in self.get_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic> { for characteristic in self.get_mut_characteristics() { if characteristic.get_type() == hap_type { return Some(characteristic); } } None } fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&dyn HapCharacteristic> = vec![ &self.current_position, &self.position_state, &self.target_position, ]; if let Some(c) = &self.current_horizontal_tilt_angle { characteristics.push(c); } if let Some(c) = &self.target_horizontal_tilt_angle { characteristics.push(c); } if let Some(c) = &self.name { characteristics.push(c); } if let Some(c) = &self.obstruction_detected { characteristics.push(c); } if let Some(c) = &self.hold_position { characteristics.push(c); } if let Some(c) = &self.current_vertical_tilt_angle { characteristics.push(c); } if let Some(c) = &self.target_vertical_tilt_angle { characteristics.push(c); } characteristics } fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic> { #[allow(unused_mut)] let mut characteristics: Vec<&mut dyn HapCharacteristic> = vec![ &mut self.current_position, &mut self.position_state, &mut self.target_position, ]; if let Some(c) = &mut self.current_horizontal_tilt_angle { characteristics.push(c); } if let Some(c) = &mut self.target_horizontal_tilt_angle { characteristics.push(c); } if let Some(c) = &mut self.name { characteristics.push(c); } if let Some(c) = &mut self.obstruction_detected { characteristics.push(c); } if let Some(c) = &mut self.hold_position { characteristics.push(c); } if let Some(c) = &mut self.current_vertical_tilt_angle { characteristics.push(c); } if let Some(c) = &mut self.target_vertical_tilt_angle { characteristics.push(c); } characteristics } } impl Serialize for WindowCoveringService { fn serialize(&self, serializer: S) -> Result { let mut state = serializer.serialize_struct("HapService", 5)?; state.serialize_field("iid", &self.get_id())?; state.serialize_field("type", &self.get_type())?; state.serialize_field("hidden", &self.get_hidden())?; state.serialize_field("primary", &self.get_primary())?; state.serialize_field("characteristics", &self.get_characteristics())?; // linked services left out for now state.end() } } ================================================ FILE: src/service/mod.rs ================================================ use erased_serde::serialize_trait_object; use crate::{characteristic::HapCharacteristic, HapType}; mod generated; pub use crate::service::generated::*; /// [`HapService`](HapService) is implemented by every HAP service. pub trait HapService: erased_serde::Serialize + Send + Sync { /// Returns the ID of the service. fn get_id(&self) -> u64; /// Sets the ID of the service. fn set_id(&mut self, id: u64); /// Returns the [`HapType`](HapType) of the service. fn get_type(&self) -> HapType; /// Sets the [`HapType`](HapType) of the service. fn set_type(&mut self, hap_type: HapType); /// Returns the `hidden` value of the service. fn get_hidden(&self) -> bool; /// Sets the `hidden` value of the service. fn set_hidden(&mut self, hidden: bool); /// Returns the `primary` value of the service. fn get_primary(&self) -> bool; /// Sets the `primary` value of the service. fn set_primary(&mut self, primary: bool); /// Returns the `linked_services` value of the service. fn get_linked_services(&self) -> Vec; /// Sets the `linked_services` value of the service. fn set_linked_services(&mut self, linked_services: Vec); /// Returns a reference to a specific characteristic of the service if it's present on it. fn get_characteristic(&self, hap_type: HapType) -> Option<&dyn HapCharacteristic>; /// Returns a mutable reference to a specific characteristic of the service if it's present on it. fn get_mut_characteristic(&mut self, hap_type: HapType) -> Option<&mut dyn HapCharacteristic>; /// Returns references to all characteristics of the service. fn get_characteristics(&self) -> Vec<&dyn HapCharacteristic>; /// Returns mutable references to all characteristics of the service. fn get_mut_characteristics(&mut self) -> Vec<&mut dyn HapCharacteristic>; } serialize_trait_object!(HapService); ================================================ FILE: src/storage/accessory_database.rs ================================================ use std::sync::Arc; use futures::lock::Mutex; use log::debug; use serde_json::json; use crate::{ accessory::HapAccessory, characteristic::Perm, pointer, transport::http::{ReadResponseObject, Status, WriteObject, WriteResponseObject}, Error, Result, }; /// `AccessoryDatabase` is a wrapper type holding a list of accessories. pub struct AccessoryDatabase { pub accessories: Vec, event_emitter: pointer::EventEmitter, } impl AccessoryDatabase { /// Creates a new `AccessoryDatabase`. pub fn new(event_emitter: pointer::EventEmitter) -> AccessoryDatabase { AccessoryDatabase { accessories: Vec::new(), event_emitter, } } /// Adds an accessory to the `AccessoryDatabase` and returns a pointer to the added accessory. pub fn add_accessory(&mut self, accessory: Box) -> Result { let mut accessory = accessory; accessory.set_event_emitter_on_characteristics(Some(self.event_emitter.clone())); let accessory = Arc::new(Mutex::new(accessory)); self.accessories.push(accessory.clone()); // TODO: some error handling here? Ok(accessory) } /// Takes a pointer to an accessory and removes the accessory from the `AccessoryDatabase`. pub async fn remove_accessory(&mut self, accessory: &pointer::Accessory) -> Result<()> { let accessory = accessory.lock().await; let mut remove = None; for (i, a) in self.accessories.iter_mut().enumerate() { if a.lock().await.get_id() == accessory.get_id() { a.lock().await.set_event_emitter_on_characteristics(None); remove = Some(i); break; } } if let Some(i) = remove { self.accessories.remove(i); return Ok(()); } Err(Error::AccessoryNotFound) } /// Reads the value of a characteristic. pub(crate) async fn read_characteristic( &self, aid: u64, iid: u64, meta: bool, perms: bool, hap_type: bool, ev: bool, ) -> Result { let mut result_object = ReadResponseObject { iid, aid, hap_type: None, format: None, perms: None, ev: None, value: None, unit: None, max_value: None, min_value: None, step_value: None, max_len: None, status: Some(0), }; 'l: for accessory in self.accessories.iter() { let mut a = accessory.lock().await; if a.get_id() == aid { for service in a.get_mut_services() { for characteristic in service.get_mut_characteristics() { if characteristic.get_id() == iid { let characteristic_perms = characteristic.get_perms(); if characteristic_perms.contains(&Perm::PairedRead) { result_object.value = Some(characteristic.get_value().await?); if meta { result_object.format = Some(characteristic.get_format()); result_object.unit = characteristic.get_unit(); result_object.max_value = characteristic.get_max_value(); result_object.min_value = characteristic.get_min_value(); result_object.step_value = characteristic.get_step_value(); result_object.max_len = characteristic.get_max_len(); } if perms { result_object.perms = Some(characteristic_perms); } if hap_type { result_object.hap_type = Some(characteristic.get_type()); } if ev { result_object.ev = characteristic.get_event_notifications(); } } else { result_object.status = Some(Status::WriteOnlyCharacteristic as i32); } break 'l; } } } } } Ok(result_object) } /// Writes the value of a characteristic. pub(crate) async fn write_characteristic( &mut self, write_object: WriteObject, event_subscriptions: &pointer::EventSubscriptions, ) -> Result { let mut result_object = WriteResponseObject { aid: write_object.aid, iid: write_object.iid, status: 0, }; 'l: for accessory in self.accessories.iter_mut() { let mut a = accessory.lock().await; if a.get_id() == write_object.aid { for service in a.get_mut_services() { for characteristic in service.get_mut_characteristics() { if characteristic.get_id() == write_object.iid { let characteristic_perms = characteristic.get_perms(); if let Some(ev) = write_object.ev { if characteristic_perms.contains(&Perm::Events) { characteristic.set_event_notifications(Some(ev)); let subscription = (write_object.aid, write_object.iid); let mut es = event_subscriptions.lock().await; let pos = es.iter().position(|&s| s == subscription); match (ev, pos) { (true, None) => { es.push(subscription); }, (false, Some(p)) => { es.remove(p); }, _ => {}, } } else { result_object.status = Status::NotificationNotSupported as i32; } } if let Some(value) = write_object.value { if characteristic_perms.contains(&Perm::PairedWrite) { characteristic.set_value(value).await?; } else { result_object.status = Status::ReadOnlyCharacteristic as i32; } } break 'l; } } } } } Ok(result_object) } pub(crate) async fn as_serialized_json(&self) -> Result> { let mut accessory_values = Vec::new(); for accessory in &self.accessories { let a = accessory.lock().await; accessory_values.push(serde_json::to_value(&*a)?); } let json = json!({ "accessories": accessory_values }); debug!("accessory list JSON: {}", &json); Ok(serde_json::to_vec(&json)?) } } // #[cfg(test)] // mod tests { // use super::*; // #[test] // fn test_json_serialization() {} // TODO: test it // } ================================================ FILE: src/storage/file_storage.rs ================================================ use async_trait::async_trait; use log::debug; use std::{ env, ffi::OsStr, fs, io::{BufReader, BufWriter, Read, Write}, path::{Path, PathBuf}, str, }; use tokio::task::spawn_blocking; use uuid::Uuid; use crate::{pairing::Pairing, storage::Storage, Config, Error, Result}; /// [`FileStorage`](FileStorage) is an implementor of the [`Storage`](Storage) trait that stores data to the file /// system. #[derive(Debug)] pub struct FileStorage { dir_path: PathBuf, } impl FileStorage { /// Creates a new [`FileStorage`](FileStorage). pub async fn new + ?Sized>(dir: &D) -> Result { let dir_path = Path::new(dir).to_path_buf(); let dir_path = spawn_blocking(move || -> Result { fs::create_dir_all(&dir_path)?; let dir_path_str = dir_path.to_str().expect("couldn't stringify current_dir"); // create subdirectory for pairings fs::create_dir_all(&format!("{}/pairings", dir_path_str))?; // create subdirectory for custom byte storage fs::create_dir_all(&format!("{}/misc", dir_path_str))?; Ok(dir_path) }) .await??; Ok(FileStorage { dir_path }) } /// Creates a new [`FileStorage`](FileStorage) with the current directory as storage path. pub async fn current_dir() -> Result { let current_dir = spawn_blocking(move || -> Result { env::current_dir().map_err(Error::from) }).await??; let current_dir = current_dir.to_str().expect("couldn't stringify current_dir"); let data_path = format!("{}/data", current_dir); Self::new(&data_path).await } fn storage_path(&self, fd: &str) -> PathBuf { let mut fd_path = self.dir_path.clone(); fd_path.push(fd); fd_path } async fn get_reader(&self, file: &str) -> Result> { let file_path = self.storage_path(file); let reader = spawn_blocking(move || -> Result> { let file = fs::OpenOptions::new().read(true).open(file_path)?; let reader = BufReader::new(file); Ok(reader) }) .await??; Ok(reader) } async fn get_writer(&self, file: &str) -> Result> { let file_path = self.storage_path(file); let writer = spawn_blocking(move || -> Result> { let file = fs::OpenOptions::new() .write(true) .create(true) .truncate(true) .open(file_path)?; let writer = BufWriter::new(file); Ok(writer) }) .await??; Ok(writer) } async fn read_bytes(&self, key: &str) -> Result> { let mut reader = self.get_reader(key).await?; let value = spawn_blocking(move || -> Result> { let mut value = Vec::new(); reader.read_to_end(&mut value)?; Ok(value) }) .await??; Ok(value) } async fn write_bytes(&self, key: &str, value: Vec) -> Result<()> { let mut writer = self.get_writer(key).await?; spawn_blocking(move || -> Result<()> { writer.write_all(&value)?; Ok(()) }) .await??; Ok(()) } async fn remove_file(&self, key: &str) -> Result<()> { let file_path = self.storage_path(key); spawn_blocking(move || -> Result<()> { fs::remove_file(file_path)?; Ok(()) }) .await??; Ok(()) } async fn list_files(&self, dir: PathBuf) -> Result> { let file_names = spawn_blocking(move || -> Result> { let mut file_names = Vec::new(); for entry in fs::read_dir(dir)? { let entry = entry?; let path = entry.path(); let file_name = path.into_os_string().into_string().or(Err(Error::Storage))?; file_names.push(file_name); } Ok(file_names) }) .await??; Ok(file_names) } } #[async_trait] impl Storage for FileStorage { async fn load_config(&self) -> Result { let config_bytes = self.read_bytes("config.json").await?; let config = serde_json::from_slice(&config_bytes)?; debug!("loaded Config: {:?}", &config); Ok(config) } async fn save_config(&mut self, config: &Config) -> Result<()> { let config_bytes = serde_json::to_vec(config)?; self.write_bytes("config.json", config_bytes).await } async fn delete_config(&mut self) -> Result<()> { self.remove_file("config.json").await } async fn load_aid_cache(&self) -> Result> { let aid_cache_bytes = self.read_bytes("aid_cache.json").await?; let aid_cache = serde_json::from_slice(&aid_cache_bytes)?; debug!("loaded AID cache: {:?}", &aid_cache); Ok(aid_cache) } async fn save_aid_cache(&mut self, aid_cache: &[u64]) -> Result<()> { let aid_cache_bytes = serde_json::to_vec(aid_cache)?; self.write_bytes("aid_cache.json", aid_cache_bytes).await } async fn delete_aid_cache(&mut self) -> Result<()> { self.remove_file("aid_cache.json").await } async fn load_pairing(&self, id: &Uuid) -> Result { let key = format!("pairings/{}.json", id.to_string()); let pairing_bytes = self.read_bytes(&key).await?; let pairing = Pairing::from_bytes(&pairing_bytes)?; debug!("loaded Pairing: {:?}", &pairing); Ok(pairing) } async fn save_pairing(&mut self, pairing: &Pairing) -> Result<()> { let key = format!("pairings/{}.json", pairing.id.to_string()); let pairing_bytes = pairing.as_bytes()?; self.write_bytes(&key, pairing_bytes).await } async fn delete_pairing(&mut self, id: &Uuid) -> Result<()> { let key = format!("pairings/{}.json", id.to_string()); self.remove_file(&key).await } async fn list_pairings(&self) -> Result> { let pairing_dir = self.storage_path("pairings"); let mut pairings = Vec::new(); for key in self.list_files(pairing_dir).await? { let pairing_bytes = self.read_bytes(&key).await?; let pairing = Pairing::from_bytes(&pairing_bytes)?; pairings.push(pairing); } Ok(pairings) } async fn count_pairings(&self) -> Result { let pairing_dir = self.storage_path("pairings"); let count = self.list_files(pairing_dir).await?.len(); Ok(count) } async fn load_bytes(&self, key: &str) -> Result> { let bytes = self.read_bytes(&format!("misc/{}", key)).await?; Ok(bytes) } async fn save_bytes(&mut self, key: &str, value: &[u8]) -> Result<()> { self.write_bytes(&format!("misc/{}", key), value.to_vec()).await } async fn delete_bytes(&mut self, key: &str) -> Result<()> { self.remove_file(&format!("misc/{}", key)).await } } #[cfg(test)] mod tests { use super::*; use crate::{pairing::Permissions, BonjourStatusFlag}; /// Ensure we can write a [`Config`](Config), then a shorter one, without corrupting data. #[tokio::test] async fn test_config_storage() { let mut config = Default::default(); let mut temp_dir = std::env::temp_dir(); temp_dir.push("hap"); let mut storage = FileStorage::new(&temp_dir).await.unwrap(); // Config can't derive PartialEq let config_eq = |a: &Config, b: &Config| { assert_eq!(a.host, b.host); assert_eq!(a.port, b.port); assert_eq!(a.pin, b.pin); assert_eq!(a.name, b.name); assert_eq!(a.device_id, b.device_id); assert_eq!(a.configuration_number, b.configuration_number); assert_eq!(a.state_number, b.state_number); assert_eq!(a.category, b.category); assert_eq!(a.protocol_version, b.protocol_version); assert_eq!(a.status_flag, b.status_flag); assert_eq!(a.feature_flag, b.feature_flag); assert_eq!(a.max_peers, b.max_peers); }; storage.save_config(&config).await.unwrap(); // config should be correctly saved let saved_config = storage.load_config().await.unwrap(); config_eq(&saved_config, &config); config.status_flag = BonjourStatusFlag::Zero; storage.save_config(&config).await.unwrap(); // config should be correctly updated (Config can't derive PartialEq) let saved_config = storage.load_config().await.unwrap(); config_eq(&saved_config, &config); storage.delete_config().await.unwrap(); // config should be deleted let saved_config = storage.load_config().await; assert!(saved_config.is_err()); } #[tokio::test] async fn test_aid_cache_storage() { let mut aid_cache = vec![1, 2, 3, 4]; let mut temp_dir = std::env::temp_dir(); temp_dir.push("hap"); let mut storage = FileStorage::new(&temp_dir).await.unwrap(); storage.save_aid_cache(&aid_cache).await.unwrap(); // aid_cache should be correctly saved let saved_aid_cache = storage.load_aid_cache().await.unwrap(); assert_eq!(saved_aid_cache, aid_cache); aid_cache.push(5); storage.save_aid_cache(&aid_cache).await.unwrap(); // aid_cache should be correctly updated let saved_aid_cache = storage.load_aid_cache().await.unwrap(); assert_eq!(saved_aid_cache, aid_cache); storage.delete_aid_cache().await.unwrap(); // aid_cache should be deleted let saved_aid_cache = storage.load_aid_cache().await; assert!(saved_aid_cache.is_err()); } /// Ensure we can correctly create, read, list and delete [`Pairing`](Pairing)s. #[tokio::test] async fn test_pairing_storage() { let pairing = Pairing { id: Uuid::parse_str("bc158b86-cabf-432d-aee4-422ef0e3f1d5").unwrap(), permissions: Permissions::Admin, public_key: [ 215, 90, 152, 1, 130, 177, 10, 183, 213, 75, 254, 211, 201, 100, 7, 58, 14, 225, 114, 243, 218, 166, 35, 37, 175, 2, 26, 104, 247, 7, 81, 26, ], }; let mut temp_dir = std::env::temp_dir(); temp_dir.push("hap"); let mut storage = FileStorage::new(&temp_dir).await.unwrap(); // a fresh file storage should count 0 pairings, list an empty Vec, and error on a non-existent ID let pairing_count = storage.count_pairings().await.unwrap(); assert_eq!(pairing_count, 0); let pairings = storage.list_pairings().await.unwrap(); assert_eq!(pairings, vec![]); let saved_pairing = storage.load_pairing(&pairing.id).await; assert!(saved_pairing.is_err()); // save a pairing storage.save_pairing(&pairing).await.unwrap(); // after saving the first pairing, we should be able to count, load and list it let pairing_count = storage.count_pairings().await.unwrap(); assert_eq!(pairing_count, 1); let pairings = storage.list_pairings().await.unwrap(); assert_eq!(pairings.len(), 1); assert_eq!(&pairings[0], &pairing); let saved_pairing = storage.load_pairing(&pairing.id).await.unwrap(); assert_eq!(&saved_pairing, &pairing); // delete the pairing storage.delete_pairing(&pairing.id).await.unwrap(); // after deleting the previously saved pairing, it should count 0 again, list an empty // Vec and error on the now non-existent ID of the deleted pairing let pairing_count = storage.count_pairings().await.unwrap(); assert_eq!(pairing_count, 0); let pairings = storage.list_pairings().await.unwrap(); assert_eq!(pairings, vec![]); let saved_pairing = storage.load_pairing(&pairing.id).await; assert!(saved_pairing.is_err()); } #[tokio::test] async fn test_byte_storage() { let mut bytes = vec![1, 2, 3, 4]; let mut temp_dir = std::env::temp_dir(); temp_dir.push("hap"); let mut storage = FileStorage::new(&temp_dir).await.unwrap(); storage.save_bytes("my_custom_bytes", &bytes).await.unwrap(); // bytes should be correctly saved let saved_bytes = storage.load_bytes("my_custom_bytes").await.unwrap(); assert_eq!(saved_bytes, bytes); bytes.push(5); storage.save_bytes("my_custom_bytes", &bytes).await.unwrap(); // bytes should be correctly updated let saved_bytes = storage.load_bytes("my_custom_bytes").await.unwrap(); assert_eq!(saved_bytes, bytes); storage.delete_bytes("my_custom_bytes").await.unwrap(); // bytes should be deleted let saved_bytes = storage.load_bytes("my_custom_bytes").await; assert!(saved_bytes.is_err()); } } ================================================ FILE: src/storage/mod.rs ================================================ mod file_storage; mod storage; pub(crate) mod accessory_database; pub use self::{file_storage::FileStorage, storage::Storage}; ================================================ FILE: src/storage/storage.rs ================================================ use async_trait::async_trait; use uuid::Uuid; use crate::{pairing::Pairing, Config, Result}; /// [`Storage`](Storage) is implemented by the persistent data storage methods HAP supports. Currently, that's just /// [`FileStorage`](crate::storage::FileStorage). #[async_trait] pub trait Storage: Send + Sync { /// Loads the [`Config`](Config) from the [`Storage`](Storage). async fn load_config(&self) -> Result; /// Saves the [`Config`](Config) to the [`Storage`](Storage). async fn save_config(&mut self, config: &Config) -> Result<()>; /// Deletes the [`Config`](Config) from the [`Storage`](Storage). async fn delete_config(&mut self) -> Result<()>; /// Loads the AID cache from the [`Storage`](Storage). async fn load_aid_cache(&self) -> Result>; /// Saves the AID cache to the [`Storage`](Storage). async fn save_aid_cache(&mut self, aid_cache: &[u64]) -> Result<()>; /// Deletes the AID cache from the [`Storage`](Storage). async fn delete_aid_cache(&mut self) -> Result<()>; /// Loads a [`Pairing`](Pairing) from the [`Storage`](Storage). async fn load_pairing(&self, id: &Uuid) -> Result; /// Saves a [`Pairing`](Pairing) to the [`Storage`](Storage). async fn save_pairing(&mut self, pairing: &Pairing) -> Result<()>; /// Deletes the [`Pairing`](Pairing) from the [`Storage`](Storage). async fn delete_pairing(&mut self, id: &Uuid) -> Result<()>; /// Loads all [`Pairing`](Pairing)s from the [`Storage`](Storage). async fn list_pairings(&self) -> Result>; /// Returns the count of [`Pairing`](Pairing)s stored on the [`Storage`](Storage). async fn count_pairings(&self) -> Result; /// Loads arbitrary bytes from the [`Storage`](Storage). async fn load_bytes(&self, key: &str) -> Result>; /// Saves arbitrary bytes to the [`Storage`](Storage). async fn save_bytes(&mut self, key: &str, value: &[u8]) -> Result<()>; /// Deletes a set of arbitrary bytes from the [`Storage`](Storage). async fn delete_bytes(&mut self, key: &str) -> Result<()>; } ================================================ FILE: src/tlv.rs ================================================ use std::{cell, collections::HashMap, io, str}; use byteorder::{LittleEndian, WriteBytesExt}; use log::error; use srp::types::SrpAuthError; use thiserror::Error; use crate::{error, pairing::Permissions}; /// Encodes a `Vec<(u8, Vec)>` in the format `(, )` to a `Vec` of concatenated TLVs. pub fn encode(tlvs: Vec<(u8, Vec)>) -> Vec { let mut vec: Vec = Vec::new(); for (t, v) in tlvs { let length = v.len(); if length <= 255 { vec.push(t); vec.push(length as u8); for byte in v { vec.push(byte); } } else { let mut l = length; let mut p = 0; while l > 255 { vec.push(t); vec.push(255); for byte in &v[p..(p + 255)] { vec.push(*byte); } l -= 255; p += 255; } if l > 0 { vec.push(t); vec.push(l as u8); for byte in &v[p..(p + l)] { vec.push(*byte); } } } } vec } /// Decodes a slice of concatenated TLVs to a `HashMap>` in the format ``. pub fn decode(tlv: &[u8]) -> HashMap> { let mut hm = HashMap::new(); let mut buf: Vec = Vec::new(); let mut p = 0; let mut pt = 0; while p < tlv.len() { let t = tlv[p]; let l = tlv[p + 1]; if l < 255 { if t != pt && !buf.is_empty() { hm.insert(t, buf.clone()); buf.clear(); } buf.extend_from_slice(&tlv[p + 2..p + 2 + l as usize]); hm.insert(t, buf.clone()); buf.clear(); } else { buf.extend_from_slice(&tlv[p + 2..p + 2 + l as usize]); } pt = t; p = p + 2 + l as usize; } if !buf.is_empty() { hm.insert(pt, buf.clone()); buf.clear(); } hm } /// `Encodable` is implemented by types that can be encoded to a to a `Vec` of concatenated /// TLVs. pub trait Encodable { fn encode(self) -> Vec; } /// `Type` represents the TLV types defined by the protocol. #[derive(Debug, Copy, Clone)] pub enum Type { Method = 0x00, Identifier = 0x01, Salt = 0x02, PublicKey = 0x03, Proof = 0x04, EncryptedData = 0x05, State = 0x06, Error = 0x07, RetryDelay = 0x08, Certificate = 0x09, Signature = 0x0A, Permissions = 0x0B, FragmentData = 0x0C, FragmentLast = 0x0D, /// Pairing Type Flags (32 bit unsigned integer). Flags = 0x13, Separator = 0xFF, } /// The variants of `Value` can hold the corresponding values to the types provided by `Type`. #[allow(dead_code)] #[derive(Debug, Clone)] pub enum Value { Method(Method), Identifier(String), Salt([u8; 16]), PublicKey(Vec), Proof(Vec), EncryptedData(Vec), State(u8), Error(Error), RetryDelay(usize), Certificate(Vec), Signature(Vec), Permissions(Permissions), FragmentData(Vec), FragmentLast(Vec), Flags(u32), Separator, } impl Value { /// Converts a variant of `Value` to a `(u8, Vec)` tuple in the format `(Type, Value)`. pub fn as_tlv(self) -> (u8, Vec) { match self { Value::Method(method) => (Type::Method as u8, vec![method as u8]), Value::Identifier(identifier) => (Type::Identifier as u8, identifier.into_bytes()), Value::Salt(salt) => (Type::Salt as u8, salt.to_vec()), Value::PublicKey(public_key) => (Type::PublicKey as u8, public_key), Value::Proof(proof) => (Type::Proof as u8, proof), Value::EncryptedData(data) => (Type::EncryptedData as u8, data), Value::State(state) => (Type::State as u8, vec![state]), Value::Error(error) => (Type::Error as u8, vec![error as u8]), Value::RetryDelay(delay) => { let val = delay as u16; let mut vec: Vec = Vec::new(); vec.write_u16::(val).unwrap(); (Type::RetryDelay as u8, vec) }, Value::Certificate(certificate) => (Type::Certificate as u8, certificate), Value::Signature(signature) => (Type::Signature as u8, signature), Value::Permissions(permissions) => (Type::Permissions as u8, vec![permissions.as_byte()]), Value::FragmentData(fragment_data) => (Type::FragmentData as u8, fragment_data), Value::FragmentLast(fragment_last) => (Type::FragmentLast as u8, fragment_last), Value::Flags(flags) => { let mut vec: Vec = Vec::new(); vec.write_u32::(flags).unwrap(); (Type::Flags as u8, vec) }, Value::Separator => (Type::Separator as u8, vec![0x00]), } } } #[allow(dead_code)] #[derive(Debug, Copy, Clone)] pub enum Method { PairSetup = 1, PairVerify = 2, AddPairing = 3, RemovePairing = 4, ListPairings = 5, } #[allow(dead_code)] #[derive(Debug, Copy, Clone, Error)] pub enum Error { #[error("Generic error to handle unexpected errors.")] Unknown = 0x01, #[error("Setup code or signature verification failed.")] Authentication = 0x02, #[error("Client must look at the retry delay TLV item and wait that many seconds before retrying.")] Backoff = 0x03, #[error("Server cannot accept any more pairings.")] MaxPeers = 0x04, #[error("Server reached its maximum number of authentication attempts.")] MaxTries = 0x05, #[error("Server pairing method is unavailable.")] Unavailable = 0x06, #[error("Server is busy and cannot accept a pairing request at this time.")] Busy = 0x07, } impl From for Error { fn from(err: error::Error) -> Self { error!("{:?}", err); Error::Unknown } } impl From for Error { fn from(err: io::Error) -> Self { error!("{:?}", err); Error::Unknown } } impl From for Error { fn from(err: cell::BorrowError) -> Error { error!("{:?}", err); Error::Unknown } } impl From for Error { fn from(err: cell::BorrowMutError) -> Error { error!("{:?}", err); Error::Unknown } } impl From for Error { fn from(err: tokio::task::JoinError) -> Self { error!("{:?}", err); Error::Unknown } } impl From for Error { fn from(err: str::Utf8Error) -> Self { error!("{:?}", err); Error::Unknown } } impl From for Error { fn from(err: uuid::Error) -> Self { error!("{:?}", err); Error::Unknown } } impl From for Error { fn from(err: SrpAuthError) -> Self { error!("{:?}", err); Error::Authentication } } impl From for Error { fn from(err: aead::Error) -> Self { error!("{:?}", err); Error::Authentication } } impl From for Error { fn from(err: ed25519_dalek::SignatureError) -> Self { error!("{:?}", err); Error::Authentication } } pub type Container = Vec; impl Encodable for Container { fn encode(self) -> Vec { encode(self.into_iter().map(|v| v.as_tlv()).collect::>()) } } pub struct ErrorContainer { step: u8, error: Error, } impl ErrorContainer { pub fn new(step: u8, error: Error) -> ErrorContainer { ErrorContainer { step, error } } } impl Encodable for ErrorContainer { fn encode(self) -> Vec { vec![Value::State(self.step), Value::Error(self.error)].encode() } } ================================================ FILE: src/transport/bonjour.rs ================================================ use serde::{Deserialize, Serialize}; /// Bonjour Feature Flag. #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum BonjourFeatureFlag { Zero = 0, SupportsHardwareAuthentication = 0x01, SupportsSoftwareAuthentication = 0x02, } /// Bonjour Status Flag. #[derive(Debug, Copy, Clone, Serialize, Deserialize, PartialEq, Eq)] pub enum BonjourStatusFlag { Zero = 0, /// Accessory has not been paired with any controllers. NotPaired = 0x01, /// Accessory has not been configured to join a Wi-Fi network. WifiNotConfigured = 0x02, /// A problem has been detected on the accessory. ProblemDetected = 0x04, } ================================================ FILE: src/transport/http/handler/accessories.rs ================================================ use futures::future::{BoxFuture, FutureExt}; use hyper::{Body, Response, StatusCode, Uri}; use log::info; use crate::{ pointer, transport::http::{handler::JsonHandlerExt, json_response}, Result, }; pub struct Accessories; impl Accessories { pub fn new() -> Accessories { Accessories } } impl JsonHandlerExt for Accessories { fn handle( &mut self, _: Uri, _: Body, _: pointer::ControllerId, _: pointer::EventSubscriptions, _: pointer::Config, _: pointer::Storage, accessory_database: pointer::AccessoryDatabase, _: pointer::EventEmitter, ) -> BoxFuture>> { info!("received list accessories request"); async move { let resp_body = accessory_database.lock().await.as_serialized_json().await?; // let resp_body = serde_json::to_vec(&accessory_database)?; json_response(resp_body, StatusCode::OK) } .boxed() } } ================================================ FILE: src/transport/http/handler/characteristics.rs ================================================ use futures::future::{BoxFuture, FutureExt}; use hyper::{body::Buf, Body, Response, StatusCode, Uri}; use log::error; use std::collections::HashMap; use url::form_urlencoded; use crate::{ pointer, transport::http::{ handler::JsonHandlerExt, json_response, status_response, CharacteristicResponseBody, ReadResponseObject, Status, WriteObject, WriteResponseObject, }, Error, Result, }; pub struct GetCharacteristics; impl GetCharacteristics { pub fn new() -> Self { GetCharacteristics } } impl JsonHandlerExt for GetCharacteristics { fn handle( &mut self, uri: Uri, _: Body, _: pointer::ControllerId, _: pointer::EventSubscriptions, _: pointer::Config, _: pointer::Storage, accessory_database: pointer::AccessoryDatabase, _: pointer::EventEmitter, ) -> BoxFuture>> { async move { if let Some(query) = uri.query() { let mut resp_body = CharacteristicResponseBody:: { characteristics: Vec::new(), }; let mut some_err = false; let mut queries: HashMap = HashMap::new(); for (key, val) in form_urlencoded::parse(query.as_bytes()) { queries.insert(key.into(), val.into()); } let (f_meta, f_perms, f_type, f_ev) = check_flags(&queries); let q_id = queries.get("id").ok_or(Error::HttpStatus(StatusCode::BAD_REQUEST))?; let ids = q_id.split(',').collect::>(); for id in ids { let id_pair = id.split('.').collect::>(); if id_pair.len() != 2 { return Err(Error::HttpStatus(StatusCode::BAD_REQUEST)); } let aid = id_pair[0].parse::()?; let iid = id_pair[1].parse::()?; let res_object = match accessory_database .lock() .await .read_characteristic(aid, iid, f_meta, f_perms, f_type, f_ev) .await { Ok(mut res_object) => { if res_object.status != Some(0) { some_err = true; res_object.value = None; } res_object }, Err(e) => { error!("error reading characteristic: {:?}", e); some_err = true; ReadResponseObject { iid, aid, status: Some(Status::ServiceCommunicationFailure as i32), ..Default::default() } }, }; resp_body.characteristics.push(res_object); } if some_err { let res = serde_json::to_vec(&resp_body)?; return json_response(res, StatusCode::MULTI_STATUS); } for ref mut r in &mut resp_body.characteristics { r.status = None; } let res = serde_json::to_vec(&resp_body)?; json_response(res, StatusCode::OK) } else { status_response(StatusCode::BAD_REQUEST) } } .boxed() } } fn check_flags(flags: &HashMap) -> (bool, bool, bool, bool) { let true_val = "1".to_string(); ( flags.get("meta") == Some(&true_val), flags.get("perms") == Some(&true_val), flags.get("type") == Some(&true_val), flags.get("ev") == Some(&true_val), ) } pub struct UpdateCharacteristics; impl UpdateCharacteristics { pub fn new() -> Self { UpdateCharacteristics {} } } impl JsonHandlerExt for UpdateCharacteristics { fn handle( &mut self, _: Uri, body: Body, _: pointer::ControllerId, event_subscriptions: pointer::EventSubscriptions, _: pointer::Config, _: pointer::Storage, accessories: pointer::AccessoryDatabase, _: pointer::EventEmitter, ) -> BoxFuture>> { async move { let aggregated_body = hyper::body::aggregate(body).await?; let write_body: CharacteristicResponseBody = serde_json::from_slice(aggregated_body.chunk())?; let mut resp_body = CharacteristicResponseBody:: { characteristics: Vec::new(), }; let mut some_err = false; let mut all_err = true; for c in write_body.characteristics { let iid = c.iid; let aid = c.aid; let res_object = match accessories .lock() .await .write_characteristic(c, &event_subscriptions) .await { Ok(res_object) => { if res_object.status != 0 { some_err = true; } else { all_err = false; } res_object }, Err(e) => { error!("error updating characteristic: {:?}", e); some_err = true; WriteResponseObject { iid, aid, status: Status::ServiceCommunicationFailure as i32, } }, }; resp_body.characteristics.push(res_object); } if all_err { let res = serde_json::to_vec(&resp_body)?; json_response(res, StatusCode::BAD_REQUEST) } else if some_err { let res = serde_json::to_vec(&resp_body)?; json_response(res, StatusCode::MULTI_STATUS) } else { status_response(StatusCode::NO_CONTENT) } } .boxed() } } ================================================ FILE: src/transport/http/handler/identify.rs ================================================ use futures::future::{BoxFuture, FutureExt}; use hyper::{Body, Response, StatusCode, Uri}; use serde_json::json; use crate::{ pointer, transport::http::{handler::JsonHandlerExt, json_response, status_response, Status}, HapType, Result, }; pub struct Identify; impl Identify { pub fn new() -> Identify { Identify } } impl JsonHandlerExt for Identify { fn handle( &mut self, _: Uri, _: Body, _: pointer::ControllerId, _: pointer::EventSubscriptions, _: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, _: pointer::EventEmitter, ) -> BoxFuture>> { let storage = storage.clone(); let accessory_database = accessory_database.clone(); async move { if storage.lock().await.count_pairings().await? > 0 { let body = serde_json::to_vec(&json!({ "status": Status::InsufficientPrivileges as i32 }))?; return json_response(body, StatusCode::BAD_REQUEST); } for accessory in accessory_database.lock().await.accessories.iter_mut() { accessory .lock() .await .get_mut_service(HapType::AccessoryInformation) .expect("missing Accessory Information Service") // every accessory needs to have it, so this should never panic .get_mut_characteristic(HapType::Identify) .expect("missing Identify Characteristic on Accessory Information Service") .set_value(serde_json::Value::Bool(true)) .await?; } // TODO: defer setting them all back to false after a few secs status_response(StatusCode::NO_CONTENT) } .boxed() } } ================================================ FILE: src/transport/http/handler/mod.rs ================================================ use futures::future::{BoxFuture, FutureExt}; use hyper::{self, Body, Response, StatusCode, Uri}; use crate::{ pointer, tlv::{self, Encodable}, transport::http::{status_response, tlv_response}, Error, Result, }; pub mod accessories; pub mod characteristics; pub mod identify; pub mod pair_setup; pub mod pair_verify; pub mod pairings; pub trait HandlerExt { fn handle( &mut self, uri: Uri, body: Body, controller_id: pointer::ControllerId, event_subscriptions: pointer::EventSubscriptions, config: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, event_emitter: pointer::EventEmitter, ) -> BoxFuture>>; } pub trait TlvHandlerExt { type ParseResult: Send; type Result: Encodable; fn parse(&self, body: Body) -> BoxFuture>; fn handle( &mut self, step: Self::ParseResult, controller_id: pointer::ControllerId, config: pointer::Config, storage: pointer::Storage, event_emitter: pointer::EventEmitter, ) -> BoxFuture>; } #[derive(Debug)] pub struct TlvHandler(T); impl From for TlvHandler { fn from(inst: T) -> TlvHandler { TlvHandler(inst) } } impl HandlerExt for TlvHandler { fn handle( &mut self, _: Uri, body: Body, controller_id: pointer::ControllerId, _: pointer::EventSubscriptions, config: pointer::Config, storage: pointer::Storage, _: pointer::AccessoryDatabase, event_emitter: pointer::EventEmitter, ) -> BoxFuture>> { async move { let response = match self.0.parse(body).await { Err(e) => e.encode(), Ok(step) => match self.0.handle(step, controller_id, config, storage, event_emitter).await { Err(e) => e.encode(), Ok(res) => res.encode(), }, }; tlv_response(response, StatusCode::OK) } .boxed() } } pub trait JsonHandlerExt { fn handle( &mut self, uri: Uri, body: Body, controller_id: pointer::ControllerId, event_subscriptions: pointer::EventSubscriptions, config: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, event_emitter: pointer::EventEmitter, ) -> BoxFuture>>; } #[derive(Debug)] pub struct JsonHandler(T); impl From for JsonHandler { fn from(inst: T) -> JsonHandler { JsonHandler(inst) } } impl HandlerExt for JsonHandler { fn handle( &mut self, uri: Uri, body: Body, controller_id: pointer::ControllerId, event_subscriptions: pointer::EventSubscriptions, config: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, event_emitter: pointer::EventEmitter, ) -> BoxFuture>> { async move { match self .0 .handle( uri, body, controller_id, event_subscriptions, config, storage, accessory_database, event_emitter, ) .await { Ok(res) => Ok(res), Err(e) => match e { Error::HttpStatus(status) => status_response(status), _ => status_response(StatusCode::INTERNAL_SERVER_ERROR), }, } } .boxed() } } ================================================ FILE: src/transport/http/handler/pair_setup.rs ================================================ use aead::{generic_array::GenericArray, AeadInPlace, NewAead}; use chacha20poly1305::ChaCha20Poly1305; use futures::future::{BoxFuture, FutureExt}; use hyper::{body::Buf, Body}; use log::{debug, info}; use num::BigUint; use rand::{rngs::OsRng, RngCore}; use sha2::{digest::Digest, Sha512}; use signature::{Signer, Verifier}; use srp::{ client::{srp_private_key, SrpClient}, groups::G_3072, server::{SrpServer, UserRecord}, types::SrpGroup, }; use std::{ops::BitXor, str}; use uuid::Uuid; use crate::{ event::Event, pairing::{Pairing, Permissions}, pointer, tlv::{self, Encodable, Type, Value}, transport::{hkdf_extract_and_expand, http::handler::TlvHandlerExt}, }; struct Session { salt: [u8; 16], verifier: Vec, b: [u8; 64], b_pub: Vec, shared_secret: Option>, } pub struct PairSetup { session: Option, unsuccessful_tries: u8, } impl PairSetup { pub fn new() -> PairSetup { PairSetup { session: None, unsuccessful_tries: 0, } } } #[derive(Debug, Clone)] enum StepNumber { Unknown = 0, SrpStartRequest = 1, SrpStartResponse = 2, SrpVerifyRequest = 3, SrpVerifyResponse = 4, ExchangeRequest = 5, ExchangeResponse = 6, } #[derive(Debug, Clone)] pub enum Step { Start, Verify { a_pub: Vec, a_proof: Vec }, Exchange { data: Vec }, } impl TlvHandlerExt for PairSetup { type ParseResult = Step; type Result = tlv::Container; fn parse(&self, body: Body) -> BoxFuture> { async { let aggregated_body = hyper::body::aggregate(body) .await .map_err(|_| tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown))?; debug!("received body: {:?}", aggregated_body.chunk()); let mut decoded = tlv::decode(aggregated_body.chunk()); match decoded.get(&(Type::State as u8)) { Some(method) => match method[0] { x if x == StepNumber::SrpStartRequest as u8 => Ok(Step::Start), x if x == StepNumber::SrpVerifyRequest as u8 => { let a_pub = decoded .remove(&(Type::PublicKey as u8)) .ok_or(tlv::ErrorContainer::new( StepNumber::SrpVerifyResponse as u8, tlv::Error::Unknown, ))?; let a_proof = decoded.remove(&(Type::Proof as u8)).ok_or(tlv::ErrorContainer::new( StepNumber::SrpVerifyResponse as u8, tlv::Error::Unknown, ))?; Ok(Step::Verify { a_pub, a_proof }) }, x if x == StepNumber::ExchangeRequest as u8 => { let data = decoded .remove(&(Type::EncryptedData as u8)) .ok_or(tlv::ErrorContainer::new( StepNumber::ExchangeResponse as u8, tlv::Error::Unknown, ))?; Ok(Step::Exchange { data }) }, _ => Err(tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown)), }, None => Err(tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown)), } } .boxed() } fn handle( &mut self, step: Step, _: pointer::ControllerId, config: pointer::Config, storage: pointer::Storage, event_emitter: pointer::EventEmitter, ) -> BoxFuture> { async move { match step { Step::Start => match handle_start(self, config).await { Ok(res) => { self.unsuccessful_tries = 0; Ok(res) }, Err(err) => { self.unsuccessful_tries += 1; Err(tlv::ErrorContainer::new(StepNumber::SrpStartResponse as u8, err)) }, }, Step::Verify { a_pub, a_proof } => match handle_verify(self, &a_pub, &a_proof).await { Ok(res) => { self.unsuccessful_tries = 0; Ok(res) }, Err(err) => { self.unsuccessful_tries += 1; Err(tlv::ErrorContainer::new(StepNumber::SrpVerifyResponse as u8, err)) }, }, Step::Exchange { data } => match handle_exchange(self, config, storage, event_emitter, &data).await { Ok(res) => { self.unsuccessful_tries = 0; Ok(res) }, Err(err) => { self.unsuccessful_tries += 1; Err(tlv::ErrorContainer::new(StepNumber::ExchangeResponse as u8, err)) }, }, } } .boxed() } } async fn handle_start(handler: &mut PairSetup, config: pointer::Config) -> Result { info!("pair setup M1: received SRP start request"); // TODO // If the accessory is already paired, it must respond with the following TLV items: // kTLVType_State // kTLVType_Error if handler.unsuccessful_tries > 100 { return Err(tlv::Error::MaxTries); } // TODO // If the accessory is currently performing a PairSetup procedure with a different controller, it must respond with // the following TLV items: // kTLVType_State // kTLVType_Error let mut csprng = OsRng {}; let mut salt = [0; 16]; // s let mut b = [0; 64]; csprng.fill_bytes(&mut salt); csprng.fill_bytes(&mut b); // TODO - respect pairing flags (specification p. 35 - 7.) for split pair setup let private_key = srp_private_key::(b"Pair-Setup", &config.lock().await.pin.to_string().as_bytes(), &salt); // x = H(s | H(I | ":" | P)) let srp_client = SrpClient::::new(&private_key, &G_3072); let verifier = srp_client.get_password_verifier(&private_key); // v = g^x let user = UserRecord { username: b"Pair-Setup", salt: &salt, verifier: &verifier, }; let srp_server = SrpServer::::new(&user, b"foo", &b, &G_3072)?; let b_pub = srp_server.get_b_pub(); handler.session = Some(Session { salt, verifier, b, b_pub: b_pub.clone(), shared_secret: None, }); info!("pair setup M2: sending SRP start response"); Ok(vec![ Value::State(StepNumber::SrpStartResponse as u8), Value::PublicKey(b_pub), Value::Salt(salt), ]) } async fn handle_verify(handler: &mut PairSetup, a_pub: &[u8], a_proof: &[u8]) -> Result { info!("pair setup M3: received SRP verify request"); match handler.session { None => Err(tlv::Error::Unknown), Some(ref mut session) => { let user = UserRecord { username: b"Pair-Setup", salt: &session.salt, verifier: &session.verifier, }; let srp_server = SrpServer::::new(&user, a_pub, &session.b, &G_3072)?; let shared_secret = srp_server.get_key(); session.shared_secret = Some(shared_secret.to_vec()); let b_proof = verify_client_proof::(&session.b_pub, a_pub, a_proof, &session.salt, &shared_secret, &G_3072)?; info!("pair setup M4: sending SRP verify response"); Ok(vec![ Value::State(StepNumber::SrpVerifyResponse as u8), Value::Proof(b_proof), ]) }, } } async fn handle_exchange( handler: &mut PairSetup, config: pointer::Config, storage: pointer::Storage, event_emitter: pointer::EventEmitter, data: &[u8], ) -> Result { info!("pair setup M5: received exchange request"); match handler.session { None => Err(tlv::Error::Unknown), Some(ref mut session) => match session.shared_secret { None => Err(tlv::Error::Unknown), Some(ref shared_secret) => { let encrypted_data = Vec::from(&data[..data.len() - 16]); let auth_tag = Vec::from(&data[data.len() - 16..]); let encryption_key = hkdf_extract_and_expand(b"Pair-Setup-Encrypt-Salt", shared_secret, b"Pair-Setup-Encrypt-Info")?; let mut nonce = vec![0; 4]; nonce.extend(b"PS-Msg05"); let aead = ChaCha20Poly1305::new(GenericArray::from_slice(&encryption_key)); let mut decrypted_data = Vec::new(); decrypted_data.extend_from_slice(&encrypted_data); aead.decrypt_in_place_detached( GenericArray::from_slice(&nonce), &[], &mut decrypted_data, GenericArray::from_slice(&auth_tag), )?; let sub_tlv = tlv::decode(&decrypted_data); let device_pairing_id = sub_tlv.get(&(Type::Identifier as u8)).ok_or(tlv::Error::Unknown)?; let device_ltpk = ed25519_dalek::PublicKey::from_bytes( sub_tlv.get(&(Type::PublicKey as u8)).ok_or(tlv::Error::Unknown)?, )?; let device_signature = ed25519_dalek::Signature::from_bytes( sub_tlv.get(&(Type::Signature as u8)).ok_or(tlv::Error::Unknown)?, )?; let device_x = hkdf_extract_and_expand( b"Pair-Setup-Controller-Sign-Salt", shared_secret, b"Pair-Setup-Controller-Sign-Info", )?; let mut device_info: Vec = Vec::new(); device_info.extend(&device_x); device_info.extend(device_pairing_id); device_info.extend(device_ltpk.as_bytes()); if device_ltpk.verify(&device_info, &device_signature).is_err() { return Err(tlv::Error::Authentication); } let uuid_str = str::from_utf8(device_pairing_id)?; let pairing_uuid = Uuid::parse_str(uuid_str)?; let mut pairing_ltpk = [0; 32]; pairing_ltpk[..32].copy_from_slice(&device_ltpk.as_bytes()[..32]); if let Some(max_peers) = config.lock().await.max_peers { if storage.lock().await.count_pairings().await? + 1 > max_peers { return Err(tlv::Error::MaxPeers); } } let pairing = Pairing::new(pairing_uuid, Permissions::Admin, device_ltpk.to_bytes()); storage.lock().await.save_pairing(&pairing).await?; debug!("pairing: {:?}", &pairing); let accessory_x = hkdf_extract_and_expand( b"Pair-Setup-Accessory-Sign-Salt", shared_secret, b"Pair-Setup-Accessory-Sign-Info", )?; let config = config.lock().await; let device_id = config.device_id.to_string(); let mut accessory_info: Vec = Vec::new(); accessory_info.extend(&accessory_x); accessory_info.extend(device_id.as_bytes()); accessory_info.extend(config.device_ed25519_keypair.public.as_bytes()); let accessory_signature = config.device_ed25519_keypair.sign(&accessory_info); let encoded_sub_tlv = vec![ Value::Identifier(device_id), Value::PublicKey(config.device_ed25519_keypair.public.as_bytes().to_vec()), Value::Signature(accessory_signature.to_bytes().to_vec()), ] .encode(); drop(config); let mut nonce = vec![0; 4]; nonce.extend(b"PS-Msg06"); let mut encrypted_data = Vec::new(); encrypted_data.extend_from_slice(&encoded_sub_tlv); let auth_tag = aead.encrypt_in_place_detached(GenericArray::from_slice(&nonce), &[], &mut encrypted_data)?; encrypted_data.extend(&auth_tag); event_emitter .lock() .await .emit(&Event::ControllerPaired { id: pairing.id }) .await; info!("pair setup M6: sending exchange response"); Ok(vec![ Value::State(StepNumber::ExchangeResponse as u8), Value::EncryptedData(encrypted_data), ]) }, }, } } fn verify_client_proof( b_pub: &[u8], a_pub: &[u8], a_proof: &[u8], salt: &[u8], key: &[u8], group: &SrpGroup, ) -> Result, tlv::Error> { let mut dhn = D::new(); dhn.update(&group.n.to_bytes_be()); let hn = BigUint::from_bytes_be(&dhn.finalize()); let mut dhg = D::new(); dhg.update(&group.g.to_bytes_be()); let hg = BigUint::from_bytes_be(&dhg.finalize()); let hng = hn.bitxor(hg); let mut dhi = D::new(); dhi.update(b"Pair-Setup"); let hi = dhi.finalize(); let mut d = D::new(); // M = H(H(N) xor H(g), H(I), s, A, B, K) d.update(&hng.to_bytes_be()); d.update(&hi); d.update(salt); d.update(a_pub); d.update(b_pub); d.update(key); if a_proof == d.finalize().as_slice() { // H(A, M, K) let mut d = D::new(); d.update(a_pub); d.update(a_proof); d.update(key); Ok(d.finalize().as_slice().to_vec()) } else { Err(tlv::Error::Authentication) } } #[cfg(test)] mod tests { use super::*; #[test] fn test_verify_client_proof() { let b_pub = [ 66, 254, 195, 54, 248, 36, 231, 56, 186, 118, 54, 42, 5, 66, 113, 73, 150, 54, 54, 156, 16, 76, 252, 50, 206, 135, 204, 173, 159, 174, 68, 125, 23, 251, 75, 215, 136, 102, 165, 73, 107, 249, 205, 158, 32, 192, 157, 134, 17, 70, 51, 225, 74, 3, 195, 74, 124, 137, 26, 48, 245, 253, 212, 197, 29, 141, 12, 5, 36, 191, 77, 203, 137, 72, 27, 38, 231, 136, 43, 60, 134, 137, 192, 134, 218, 13, 90, 232, 166, 245, 168, 29, 34, 91, 121, 185, 82, 144, 146, 215, 6, 120, 204, 126, 217, 146, 135, 243, 55, 1, 99, 159, 192, 53, 80, 103, 19, 87, 253, 193, 104, 98, 228, 167, 138, 214, 84, 135, 232, 225, 185, 158, 114, 48, 228, 110, 137, 109, 32, 21, 227, 177, 18, 241, 240, 240, 125, 115, 135, 46, 249, 172, 206, 170, 41, 76, 169, 163, 62, 77, 94, 51, 116, 69, 188, 218, 171, 90, 171, 128, 163, 84, 233, 52, 134, 77, 70, 130, 207, 84, 55, 218, 155, 199, 67, 214, 10, 25, 142, 134, 34, 65, 43, 52, 113, 92, 234, 213, 101, 32, 12, 34, 87, 31, 82, 132, 175, 144, 116, 36, 47, 119, 221, 46, 103, 44, 80, 74, 201, 196, 249, 230, 127, 123, 80, 118, 216, 163, 249, 186, 218, 184, 181, 144, 72, 187, 101, 164, 150, 209, 45, 247, 70, 184, 92, 155, 146, 175, 162, 54, 95, 155, 174, 116, 38, 190, 166, 137, 133, 51, 253, 21, 169, 129, 167, 61, 102, 49, 115, 24, 245, 130, 171, 6, 196, 177, 44, 49, 149, 39, 239, 142, 253, 49, 123, 226, 140, 40, 43, 193, 131, 20, 30, 17, 57, 252, 1, 68, 55, 1, 227, 226, 24, 73, 204, 237, 230, 2, 81, 203, 54, 204, 157, 174, 22, 134, 126, 132, 106, 66, 115, 27, 189, 157, 131, 173, 205, 36, 140, 160, 183, 171, 62, 97, 7, 73, 93, 114, 199, 50, 192, 22, 56, 132, 172, 61, 208, 84, 102, 85, 60, 216, 170, 249, 29, 66, 158, 48, 221, 78, 166, 50, 20, 203, 99, 206, 6, 112, 163, 194, 43, 165, 176, 193, 62, 157, 184, 57, 235, 221, 175, 46, 7, 152, ]; let a_pub = [ 21, 187, 129, 247, 180, 115, 7, 3, 46, 219, 190, 0, 89, 8, 126, 225, 37, 159, 98, 137, 226, 202, 13, 228, 31, 55, 17, 244, 180, 120, 159, 97, 141, 126, 131, 219, 227, 64, 81, 24, 99, 206, 12, 218, 27, 95, 43, 216, 151, 228, 46, 89, 133, 153, 100, 55, 134, 206, 65, 165, 244, 228, 121, 88, 78, 54, 19, 220, 48, 86, 150, 92, 21, 168, 219, 226, 214, 254, 33, 26, 135, 134, 247, 49, 58, 114, 245, 76, 67, 182, 223, 191, 93, 1, 131, 58, 76, 62, 49, 123, 11, 10, 164, 221, 249, 114, 77, 154, 179, 95, 207, 127, 9, 154, 30, 91, 99, 67, 160, 94, 33, 239, 178, 32, 173, 245, 25, 91, 153, 189, 34, 216, 16, 100, 160, 145, 150, 208, 85, 135, 237, 13, 225, 234, 144, 137, 224, 217, 187, 77, 10, 51, 240, 45, 72, 9, 184, 164, 195, 153, 55, 66, 98, 110, 208, 204, 45, 204, 14, 46, 195, 119, 25, 83, 120, 223, 17, 167, 79, 75, 68, 182, 105, 97, 176, 15, 153, 95, 170, 16, 33, 172, 134, 114, 73, 69, 5, 49, 78, 133, 250, 44, 136, 75, 179, 33, 213, 48, 77, 236, 16, 148, 221, 74, 185, 209, 83, 94, 167, 180, 101, 170, 91, 129, 143, 228, 180, 251, 185, 210, 16, 74, 26, 248, 65, 208, 73, 182, 161, 120, 59, 223, 98, 166, 58, 94, 69, 250, 93, 75, 29, 36, 41, 211, 242, 115, 253, 65, 28, 204, 117, 167, 194, 113, 98, 180, 54, 96, 170, 81, 125, 134, 19, 213, 2, 213, 178, 163, 108, 74, 215, 177, 52, 217, 75, 225, 144, 220, 3, 164, 87, 156, 233, 1, 99, 218, 251, 89, 45, 165, 227, 98, 232, 143, 165, 141, 246, 196, 230, 209, 136, 35, 75, 218, 63, 15, 94, 150, 79, 113, 245, 247, 28, 139, 115, 136, 232, 175, 49, 228, 11, 70, 234, 131, 126, 167, 31, 234, 202, 34, 27, 240, 195, 201, 1, 29, 98, 229, 254, 146, 87, 223, 113, 5, 218, 217, 250, 58, 115, 53, 9, 162, 175, 42, 176, 10, 195, 48, 155, 56, 58, 246, 219, 98, 166, 41, 34, 216, 225, 29, 28, 1, 18, 89, ]; let a_proof = [ 33, 202, 204, 21, 29, 11, 142, 163, 254, 113, 245, 137, 104, 89, 101, 247, 182, 215, 41, 42, 213, 171, 173, 142, 172, 183, 214, 187, 204, 48, 253, 153, 224, 246, 18, 246, 72, 5, 95, 165, 27, 245, 255, 22, 229, 250, 129, 33, 8, 40, 1, 194, 131, 19, 51, 75, 37, 179, 34, 60, 222, 13, 182, 81, ]; let salt = [67, 81, 86, 223, 10, 171, 140, 180, 0, 188, 111, 77, 228, 110, 173, 185]; let shared_secret = [ 39, 162, 132, 15, 245, 98, 72, 107, 190, 101, 117, 162, 228, 189, 241, 14, 132, 216, 104, 7, 65, 72, 90, 154, 86, 129, 171, 235, 197, 55, 174, 216, 183, 170, 12, 101, 219, 128, 62, 155, 113, 212, 250, 40, 137, 178, 199, 215, 68, 139, 218, 112, 205, 68, 52, 66, 95, 11, 116, 251, 143, 93, 206, 89, ]; let b_proof = verify_client_proof::(&b_pub, &a_pub, &a_proof, &salt, &shared_secret, &G_3072).unwrap(); assert_eq!(b_proof, vec![ 53, 222, 231, 209, 7, 123, 202, 208, 135, 119, 183, 90, 79, 154, 55, 155, 63, 56, 215, 210, 4, 20, 229, 119, 234, 168, 107, 137, 48, 172, 180, 244, 184, 142, 170, 120, 188, 106, 94, 135, 122, 4, 211, 21, 190, 26, 121, 180, 13, 192, 173, 246, 172, 223, 161, 192, 52, 251, 187, 66, 52, 170, 18, 85 ]); } } ================================================ FILE: src/transport/http/handler/pair_verify.rs ================================================ use aead::{generic_array::GenericArray, AeadInPlace, NewAead}; use chacha20poly1305::ChaCha20Poly1305; use futures::{ channel::oneshot, future::{BoxFuture, FutureExt}, }; use hyper::{body::Buf, Body}; use log::{debug, info}; use rand::rngs::OsRng; use signature::{Signer, Verifier}; use std::str; use uuid::Uuid; use x25519_dalek::{EphemeralSecret, PublicKey}; use crate::{ pointer, tlv::{self, Encodable, Type, Value}, transport::{hkdf_extract_and_expand, http::handler::TlvHandlerExt, tcp}, }; struct Session { b_pub: PublicKey, a_pub: PublicKey, shared_secret: [u8; 32], session_key: [u8; 32], } pub struct PairVerify { session: Option, session_sender: Option>, } impl PairVerify { pub fn new(session_sender: oneshot::Sender) -> PairVerify { PairVerify { session: None, session_sender: Some(session_sender), } } } #[derive(Debug, Clone)] enum StepNumber { Unknown = 0, StartReq = 1, StartRes = 2, FinishReq = 3, FinishRes = 4, } #[derive(Debug, Clone)] pub enum Step { Start { a_pub: Vec }, Finish { data: Vec }, } impl TlvHandlerExt for PairVerify { type ParseResult = Step; type Result = tlv::Container; fn parse(&self, body: Body) -> BoxFuture> { async { let aggregated_body = hyper::body::aggregate(body) .await .map_err(|_| tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown))?; debug!("received body: {:?}", aggregated_body.chunk()); let mut decoded = tlv::decode(aggregated_body.chunk()); match decoded.get(&(Type::State as u8)) { Some(method) => match method[0] { x if x == StepNumber::StartReq as u8 => { let a_pub = decoded .remove(&(Type::PublicKey as u8)) .ok_or(tlv::ErrorContainer::new( StepNumber::StartRes as u8, tlv::Error::Unknown, ))?; Ok(Step::Start { a_pub }) }, x if x == StepNumber::FinishReq as u8 => { let data = decoded .remove(&(Type::EncryptedData as u8)) .ok_or(tlv::ErrorContainer::new( StepNumber::FinishRes as u8, tlv::Error::Unknown, ))?; Ok(Step::Finish { data }) }, _ => Err(tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown)), }, None => Err(tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown)), } } .boxed() } fn handle( &mut self, step: Step, _: pointer::ControllerId, config: pointer::Config, storage: pointer::Storage, _: pointer::EventEmitter, ) -> BoxFuture> { async move { match step { Step::Start { a_pub } => match handle_start(self, config, a_pub).await { Ok(res) => Ok(res), Err(err) => Err(tlv::ErrorContainer::new(StepNumber::StartRes as u8, err)), }, Step::Finish { data } => match handle_finish(self, storage, &data).await { Ok(res) => Ok(res), Err(err) => Err(tlv::ErrorContainer::new(StepNumber::FinishRes as u8, err)), }, } } .boxed() } } async fn handle_start( handler: &mut PairVerify, config: pointer::Config, a_pub_bytes: Vec, ) -> Result { info!("pair verify M1: received verify start request"); let mut a_pub = [0; 32]; let bytes = &a_pub_bytes[..a_pub.len()]; // panics if not enough data a_pub.copy_from_slice(bytes); let a_pub = PublicKey::from(a_pub); let mut csprng = OsRng {}; let b = EphemeralSecret::new(&mut csprng); let b_pub = PublicKey::from(&b); let shared_secret = b.diffie_hellman(&a_pub); let config = config.lock().await; let device_id = config.device_id.to_string(); let mut accessory_info: Vec = Vec::new(); accessory_info.extend(b_pub.as_bytes()); accessory_info.extend(device_id.as_bytes()); accessory_info.extend(a_pub.as_bytes()); let accessory_signature = config.device_ed25519_keypair.sign(&accessory_info); drop(config); let encoded_sub_tlv = vec![ Value::Identifier(device_id), Value::Signature(accessory_signature.to_bytes().to_vec()), ] .encode(); let session_key = hkdf_extract_and_expand( b"Pair-Verify-Encrypt-Salt", shared_secret.as_bytes(), b"Pair-Verify-Encrypt-Info", )?; handler.session = Some(Session { b_pub, a_pub, shared_secret: *shared_secret.as_bytes(), session_key, }); let mut nonce = vec![0; 4]; nonce.extend(b"PV-Msg02"); let aead = ChaCha20Poly1305::new(GenericArray::from_slice(&session_key)); let mut encrypted_data = Vec::new(); encrypted_data.extend_from_slice(&encoded_sub_tlv); let auth_tag = aead.encrypt_in_place_detached(GenericArray::from_slice(&nonce), &[], &mut encrypted_data)?; encrypted_data.extend(&auth_tag); info!("pair verify M2: sending verify start response"); Ok(vec![ Value::State(StepNumber::StartRes as u8), Value::PublicKey(b_pub.as_bytes().to_vec()), Value::EncryptedData(encrypted_data), ]) } async fn handle_finish( handler: &mut PairVerify, storage: pointer::Storage, data: &[u8], ) -> Result { info!("pair verify M3: received verify finish request"); match handler.session { None => Err(tlv::Error::Unknown), Some(ref mut session) => { let encrypted_data = Vec::from(&data[..data.len() - 16]); let auth_tag = Vec::from(&data[data.len() - 16..]); let mut nonce = vec![0; 4]; nonce.extend(b"PV-Msg03"); let aead = ChaCha20Poly1305::new(GenericArray::from_slice(&session.session_key)); let mut decrypted_data = Vec::new(); decrypted_data.extend_from_slice(&encrypted_data); aead.decrypt_in_place_detached( GenericArray::from_slice(&nonce), &[], &mut decrypted_data, GenericArray::from_slice(&auth_tag), )?; let sub_tlv = tlv::decode(&decrypted_data); debug!("received sub-TLV: {:?}", &sub_tlv); let device_pairing_id = sub_tlv.get(&(Type::Identifier as u8)).ok_or(tlv::Error::Unknown)?; debug!("raw device pairing ID: {:?}", &device_pairing_id); let device_signature = ed25519_dalek::Signature::from_bytes( sub_tlv.get(&(Type::Signature as u8)).ok_or(tlv::Error::Unknown)?, )?; debug!("device signature: {:?}", &device_signature); let uuid_str = str::from_utf8(device_pairing_id)?; let pairing_uuid = Uuid::parse_str(uuid_str)?; debug!("device pairing UUID: {:?}", &pairing_uuid); let pairing = storage.lock().await.load_pairing(&pairing_uuid).await?; debug!("loaded pairing: {:?}", &pairing); let mut device_info: Vec = Vec::new(); device_info.extend(session.a_pub.as_bytes()); device_info.extend(device_pairing_id); device_info.extend(session.b_pub.as_bytes()); if ed25519_dalek::PublicKey::from_bytes(&pairing.public_key)? .verify(&device_info, &device_signature) .is_err() { return Err(tlv::Error::Authentication); } if let Some(sender) = handler.session_sender.take() { let encrypted_session = tcp::Session { controller_id: pairing_uuid, shared_secret: session.shared_secret, }; let _session = sender.send(encrypted_session); } else { return Err(tlv::Error::Unknown); } info!("pair verify M4: sending verify finish response"); Ok(vec![Value::State(StepNumber::FinishRes as u8)]) }, } } ================================================ FILE: src/transport/http/handler/pairings.rs ================================================ use futures::future::{BoxFuture, FutureExt}; use hyper::{body::Buf, Body}; use log::{debug, info}; use std::{ops::Deref, str}; use uuid::Uuid; use crate::{ event::Event, pairing::{Pairing, Permissions}, pointer, tlv::{self, Type, Value}, transport::http::handler::TlvHandlerExt, }; pub struct Pairings; impl Pairings { pub fn new() -> Pairings { Pairings } } #[derive(Debug, Clone)] enum StepNumber { Unknown = 0, Res = 2, } #[derive(Debug, Clone)] enum HandlerNumber { Add = 3, Remove = 4, List = 5, } pub enum HandlerType { Add { pairing_id: Vec, ltpk: Vec, permissions: Permissions, }, Remove { pairing_id: Vec, }, List, } impl TlvHandlerExt for Pairings { type ParseResult = HandlerType; type Result = tlv::Container; fn parse(&self, body: Body) -> BoxFuture> { async { let aggregated_body = hyper::body::aggregate(body) .await .map_err(|_| tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown))?; debug!("received body: {:?}", aggregated_body.chunk()); let mut decoded = tlv::decode(aggregated_body.chunk()); if decoded.get(&(Type::State as u8)) != Some(&vec![1]) { return Err(tlv::ErrorContainer::new(0, tlv::Error::Unknown)); } match decoded.get(&(Type::Method as u8)) { Some(handler) => match handler[0] { x if x == HandlerNumber::Add as u8 => { let pairing_id = decoded .remove(&(Type::Identifier as u8)) .ok_or(tlv::ErrorContainer::new(StepNumber::Res as u8, tlv::Error::Unknown))?; let ltpk = decoded .remove(&(Type::PublicKey as u8)) .ok_or(tlv::ErrorContainer::new(StepNumber::Res as u8, tlv::Error::Unknown))?; let perms = decoded .remove(&(Type::Permissions as u8)) .ok_or(tlv::ErrorContainer::new(StepNumber::Res as u8, tlv::Error::Unknown))?; let permissions = Permissions::from_byte(perms[0]) .map_err(|_| tlv::ErrorContainer::new(StepNumber::Res as u8, tlv::Error::Unknown))?; Ok(HandlerType::Add { pairing_id, ltpk, permissions, }) }, x if x == HandlerNumber::Remove as u8 => { let pairing_id = decoded .remove(&(Type::Identifier as u8)) .ok_or(tlv::ErrorContainer::new(StepNumber::Res as u8, tlv::Error::Unknown))?; Ok(HandlerType::Remove { pairing_id }) }, x if x == HandlerNumber::List as u8 => Ok(HandlerType::List), _ => Err(tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown)), }, None => Err(tlv::ErrorContainer::new(StepNumber::Unknown as u8, tlv::Error::Unknown)), } } .boxed() } fn handle( &mut self, handler: HandlerType, controller_id: pointer::ControllerId, config: pointer::Config, storage: pointer::Storage, event_emitter: pointer::EventEmitter, ) -> BoxFuture> { async move { match handler { HandlerType::Add { pairing_id, ltpk, permissions, } => match handle_add( controller_id, config, storage, event_emitter, pairing_id, ltpk, permissions, ) .await { Ok(res) => Ok(res), Err(err) => Err(tlv::ErrorContainer::new(StepNumber::Res as u8, err)), }, HandlerType::Remove { pairing_id } => { match handle_remove(controller_id, storage, event_emitter, pairing_id).await { Ok(res) => Ok(res), Err(err) => Err(tlv::ErrorContainer::new(StepNumber::Res as u8, err)), } }, HandlerType::List => match handle_list(controller_id, storage).await { Ok(res) => Ok(res), Err(err) => Err(tlv::ErrorContainer::new(StepNumber::Res as u8, err)), }, } } .boxed() } } async fn handle_add( controller_id: pointer::ControllerId, config: pointer::Config, storage: pointer::Storage, event_emitter: pointer::EventEmitter, pairing_id: Vec, ltpk: Vec, permissions: Permissions, ) -> Result { info!("pairings M1: received add pairing request"); check_admin(&controller_id, &storage).await?; let uuid_str = str::from_utf8(&pairing_id)?; let pairing_uuid = Uuid::parse_str(uuid_str)?; let mut s = storage.lock().await; match s.load_pairing(&pairing_uuid).await { Ok(mut pairing) => { if ed25519_dalek::PublicKey::from_bytes(&pairing.public_key)? != ed25519_dalek::PublicKey::from_bytes(<pk)? { return Err(tlv::Error::Unknown); } pairing.permissions = permissions; s.save_pairing(&pairing).await?; drop(s); event_emitter .lock() .await .emit(&Event::ControllerPaired { id: pairing.id }) .await; }, Err(_) => { if let Some(max_peers) = config.lock().await.max_peers { if s.count_pairings().await? + 1 > max_peers { return Err(tlv::Error::MaxPeers); } } let mut public_key = [0; 32]; public_key.clone_from_slice(<pk); let pairing = Pairing { id: pairing_uuid, permissions, public_key, }; s.save_pairing(&pairing).await?; drop(s); event_emitter .lock() .await .emit(&Event::ControllerPaired { id: pairing.id }) .await; }, } info!("pairings M2: sending add pairing response"); Ok(vec![Value::State(StepNumber::Res as u8)]) } async fn handle_remove( controller_id: pointer::ControllerId, storage: pointer::Storage, event_emitter: pointer::EventEmitter, pairing_id: Vec, ) -> Result { info!("pairings M1: received remove pairing request"); check_admin(&controller_id, &storage).await?; let uuid_str = str::from_utf8(&pairing_id)?; let pairing_uuid = Uuid::parse_str(uuid_str)?; storage.lock().await.delete_pairing(&pairing_uuid).await?; event_emitter .lock() .await .emit(&Event::ControllerUnpaired { id: pairing_uuid }) .await; info!("pairings M2: sending remove pairing response"); Ok(vec![Value::State(StepNumber::Res as u8)]) } async fn handle_list( controller_id: pointer::ControllerId, storage: pointer::Storage, ) -> Result { info!("pairings M1: received list pairings request"); check_admin(&controller_id, &storage).await?; let pairings = storage.lock().await.list_pairings().await?; let mut list = vec![Value::State(StepNumber::Res as u8)]; for (i, pairing) in pairings.iter().enumerate() { list.push(Value::Identifier(pairing.id.to_hyphenated().to_string())); list.push(Value::PublicKey(pairing.public_key.to_vec())); list.push(Value::Permissions(pairing.permissions.clone())); if i < pairings.len() { list.push(Value::Separator); } } info!("pairings M2: sending list pairings response"); Ok(list) } async fn check_admin(controller_id: &pointer::ControllerId, storage: &pointer::Storage) -> Result<(), tlv::Error> { let controller_id: Uuid = controller_id .read() .unwrap() .deref() .ok_or(tlv::Error::Authentication)?; match storage.lock().await.load_pairing(&controller_id).await { Err(_) => Err(tlv::Error::Authentication), Ok(controller) => match controller.permissions { Permissions::Admin => Ok(()), _ => Err(tlv::Error::Authentication), }, } } ================================================ FILE: src/transport/http/mod.rs ================================================ use hyper::{ header::{CONTENT_LENGTH, CONTENT_TYPE}, Body, Response, StatusCode, }; use serde::{Deserialize, Serialize}; use crate::{ characteristic::{Format, Perm, Unit}, Error, HapType, Result, }; mod handler; pub(crate) mod server; #[allow(dead_code)] #[derive(Debug)] pub enum Status { Success = 0, InsufficientPrivileges = -70401, ServiceCommunicationFailure = -70402, ResourceBusy = -70403, ReadOnlyCharacteristic = -70404, WriteOnlyCharacteristic = -70405, NotificationNotSupported = -70406, OutOfResource = -70407, OperationTimedOut = -70408, ResourceDoesNotExist = -70409, InvalidValueInRequest = -70410, } #[derive(Debug)] enum ContentType { PairingTLV8, HapJson, } impl ContentType { pub fn to_string(self) -> String { match self { ContentType::PairingTLV8 => "application/pairing+tlv8".into(), ContentType::HapJson => "application/hap+json".into(), } } } #[derive(Debug, Serialize, Deserialize)] pub struct CharacteristicResponseBody { characteristics: Vec, } #[derive(Debug, Default, Serialize)] pub struct ReadResponseObject { pub iid: u64, pub aid: u64, #[serde(rename = "type", skip_serializing_if = "Option::is_none")] pub hap_type: Option, #[serde(skip_serializing_if = "Option::is_none")] pub format: Option, #[serde(skip_serializing_if = "Option::is_none")] pub perms: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub ev: Option, #[serde(skip_serializing_if = "Option::is_none")] pub value: Option, #[serde(skip_serializing_if = "Option::is_none")] pub unit: Option, #[serde(rename = "maxValue", skip_serializing_if = "Option::is_none")] pub max_value: Option, #[serde(rename = "minValue", skip_serializing_if = "Option::is_none")] pub min_value: Option, #[serde(rename = "minStep", skip_serializing_if = "Option::is_none")] pub step_value: Option, #[serde(rename = "maxLen", skip_serializing_if = "Option::is_none")] pub max_len: Option, #[serde(skip_serializing_if = "Option::is_none")] pub status: Option, } #[derive(Debug, Deserialize)] pub struct WriteObject { pub iid: u64, pub aid: u64, pub ev: Option, pub value: Option, #[serde(rename = "authData")] pub auth_data: Option, pub remote: Option, } #[derive(Debug, Serialize)] pub struct WriteResponseObject { pub iid: u64, pub aid: u64, pub status: i32, } #[derive(Debug, Serialize)] pub struct EventObject { pub iid: u64, pub aid: u64, pub value: serde_json::Value, } pub fn tlv_response(body: Vec, status: StatusCode) -> Result> { response(body, status, ContentType::PairingTLV8) } pub fn json_response(body: Vec, status: StatusCode) -> Result> { response(body, status, ContentType::HapJson) } pub fn status_response(status: StatusCode) -> Result> { Response::builder() .status(status) .body(Body::empty()) .map_err(Error::from) } pub fn event_response(event_objects: Vec) -> Result> { let body = serde_json::to_string(&CharacteristicResponseBody { characteristics: event_objects, })?; let response = format!( "EVENT/1.0 200 OK\nContent-Type: {}\nContent-Length: {}\n\n{}", ContentType::HapJson.to_string(), body.len(), body, ); Ok(response.as_bytes().to_vec()) } fn response(body: Vec, status: StatusCode, content_type: ContentType) -> Result> { Response::builder() .status(status) .header(CONTENT_TYPE, content_type.to_string()) .header(CONTENT_LENGTH, body.len() as u64) .body(body.into()) .map_err(Error::from) } ================================================ FILE: src/transport/http/server.rs ================================================ use futures::{ channel::oneshot, future::{self, BoxFuture, Future, FutureExt, TryFutureExt}, lock::Mutex, }; use hyper::{server::conn::Http, service::Service, Body, Method, Request, Response, StatusCode}; use log::{debug, error, info}; use std::{ net::SocketAddr, pin::Pin, sync::Arc, task::{Context, Poll}, }; use tokio::net::TcpListener; use crate::{ event::Event, pointer, transport::{ http::{ event_response, handler::{ accessories::Accessories, characteristics::{GetCharacteristics, UpdateCharacteristics}, identify::Identify, pair_setup::PairSetup, pair_verify::PairVerify, pairings::Pairings, HandlerExt, JsonHandler, TlvHandler, }, status_response, EventObject, }, tcp::{EncryptedStream, Session, StreamWrapper}, }, Error, Result, }; struct Handlers { pub pair_setup: Arc>>, pub pair_verify: Arc>>, pub accessories: Arc>>, pub get_characteristics: Arc>>, pub put_characteristics: Arc>>, pub pairings: Arc>>, pub identify: Arc>>, } struct Api { controller_id: pointer::ControllerId, event_subscriptions: pointer::EventSubscriptions, config: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, event_emitter: pointer::EventEmitter, handlers: Handlers, } impl Api { fn new( controller_id: pointer::ControllerId, event_subscriptions: pointer::EventSubscriptions, config: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, event_emitter: pointer::EventEmitter, session_sender: oneshot::Sender, ) -> Self { Api { controller_id, event_subscriptions, config, storage, accessory_database, event_emitter, handlers: Handlers { pair_setup: Arc::new(Mutex::new(Box::new(TlvHandler::from(PairSetup::new())))), pair_verify: Arc::new(Mutex::new(Box::new(TlvHandler::from(PairVerify::new(session_sender))))), accessories: Arc::new(Mutex::new(Box::new(JsonHandler::from(Accessories::new())))), get_characteristics: Arc::new(Mutex::new(Box::new(JsonHandler::from(GetCharacteristics::new())))), put_characteristics: Arc::new(Mutex::new(Box::new(JsonHandler::from(UpdateCharacteristics::new())))), pairings: Arc::new(Mutex::new(Box::new(TlvHandler::from(Pairings::new())))), identify: Arc::new(Mutex::new(Box::new(JsonHandler::from(Identify::new())))), }, } } } impl Service> for Api { type Error = Error; type Future = Pin> + Send>>; type Response = Response; fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: Request) -> Self::Future { let (parts, body) = req.into_parts(); let method = parts.method; let uri = parts.uri; let mut handler: Option>>> = match (method, uri.path()) { (Method::POST, "/pair-setup") => Some(self.handlers.pair_setup.clone()), (Method::POST, "/pair-verify") => Some(self.handlers.pair_verify.clone()), (Method::GET, "/accessories") => Some(self.handlers.accessories.clone()), (Method::GET, "/characteristics") => Some(self.handlers.get_characteristics.clone()), (Method::PUT, "/characteristics") => Some(self.handlers.put_characteristics.clone()), (Method::POST, "/pairings") => Some(self.handlers.pairings.clone()), (Method::POST, "/identify") => Some(self.handlers.identify.clone()), _ => None, }; let controller_id = self.controller_id.clone(); let event_subscriptions = self.event_subscriptions.clone(); let config = self.config.clone(); let storage = self.storage.clone(); let accessory_database = self.accessory_database.clone(); let event_emitter = self.event_emitter.clone(); let fut = async move { match handler.take() { Some(handler) => handler .lock() .await .handle( uri, body, controller_id, event_subscriptions, config, storage, accessory_database, event_emitter, ) .await, None => future::ready(status_response(StatusCode::NOT_FOUND)).await, } } .boxed(); fut } } #[derive(Clone)] pub struct Server { config: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, event_emitter: pointer::EventEmitter, mdns_responder: pointer::MdnsResponder, } impl Server { pub fn new( config: pointer::Config, storage: pointer::Storage, accessory_database: pointer::AccessoryDatabase, event_emitter: pointer::EventEmitter, mdns_responder: pointer::MdnsResponder, ) -> Self { Server { config, storage, accessory_database, event_emitter, mdns_responder, } } pub fn run_handle(&self) -> BoxFuture> { let config = self.config.clone(); let storage = self.storage.clone(); let accessory_database = self.accessory_database.clone(); let event_emitter = self.event_emitter.clone(); let mdns_responder = self.mdns_responder.clone(); async move { let config_lock = config.lock().await; let socket_addr = SocketAddr::new(config_lock.host, config_lock.port); drop(config_lock); info!("binding TCP listener on {}", &socket_addr); let listener = TcpListener::bind(socket_addr).await?; mdns_responder.lock().await.update_records().await; loop { let (stream, _socket_addr) = listener.accept().await?; debug!("incoming TCP stream from {}", stream.peer_addr()?); let ( encrypted_stream, stream_incoming, stream_outgoing, session_sender, incoming_waker, outgoing_waker, ) = EncryptedStream::new(stream); let stream_wrapper = StreamWrapper::new(stream_incoming, stream_outgoing.clone(), incoming_waker, outgoing_waker); let event_subscriptions = Arc::new(Mutex::new(vec![])); let api = Api::new( encrypted_stream.controller_id.clone(), event_subscriptions.clone(), config.clone(), storage.clone(), accessory_database.clone(), event_emitter.clone(), session_sender, ); event_emitter.lock().await.add_listener(Box::new(move |event| { let event_subscriptions_ = event_subscriptions.clone(); let stream_outgoing_ = stream_outgoing.clone(); async move { match *event { Event::CharacteristicValueChanged { aid, iid, ref value } => { let mut dropped_subscriptions = vec![]; for (i, &(s_aid, s_iid)) in event_subscriptions_.lock().await.iter().enumerate() { if s_aid == aid && s_iid == iid { let event = EventObject { aid, iid, value: value.clone(), }; let event_res = event_response(vec![event]).expect("couldn't create event response"); if stream_outgoing_.unbounded_send(event_res).is_err() { dropped_subscriptions.push(i); } } } let mut ev = event_subscriptions_.lock().await; for s in dropped_subscriptions { ev.remove(s); } }, _ => {}, } } .boxed() })); let mut http = Http::new(); http.http1_only(true); http.http1_half_close(true); http.http1_keep_alive(true); http.http1_preserve_header_case(true); tokio::spawn(encrypted_stream.map_err(|e| error!("{:?}", e)).map(|_| ())); tokio::spawn( http.serve_connection(stream_wrapper, api) .map_err(|e| error!("{:?}", e)) .map(|_| ()), ); } #[allow(unreachable_code)] Ok(()) } .boxed() } } ================================================ FILE: src/transport/mdns.rs ================================================ use libmdns::{Responder, Service}; use log::debug; use crate::pointer; /// An mDNS Responder. Used to announce the Accessory's name and HAP TXT records to potential controllers. pub struct MdnsResponder { config: pointer::Config, responder: Responder, service: Option, task: Option + Unpin + std::marker::Send>>, } impl MdnsResponder { /// Creates a new mDNS Responder. pub async fn new(config: pointer::Config) -> Self { let (responder, task) = libmdns::Responder::with_default_handle().expect("creating mDNS responder"); MdnsResponder { config, responder, service: None, task: Some(task), } } /// Derives new mDNS TXT records from the server's `Config`. pub async fn update_records(&mut self) { debug!("attempting to set mDNS records"); self.service = None; let c = self.config.lock().await; let name = c.name.clone(); let port = c.port; let tr = c.txt_records(); drop(c); self.service = Some(self.responder.register("_hap._tcp".into(), name, port, &[ &tr[0], &tr[1], &tr[2], &tr[3], &tr[4], &tr[5], &tr[6], &tr[7], ])); debug!("setting mDNS records: {:?}", &tr); } /// Returns the mDNS task to throw on a scheduler. pub fn run_handle(&mut self) -> Box + Unpin + std::marker::Send> { match self.task.take() { Some(task) => task, // if the task handle is gone, recreate the whole responder None => { let (responder, task) = libmdns::Responder::with_default_handle().expect("creating mDNS responder"); self.responder = responder; task }, } } } ================================================ FILE: src/transport/mod.rs ================================================ use hkdf::Hkdf; use sha2::Sha512; use crate::{Error, Result}; pub(crate) mod bonjour; pub(crate) mod http; pub(crate) mod mdns; pub(crate) mod tcp; pub(crate) fn hkdf_extract_and_expand(salt: &[u8], ikm: &[u8], info: &[u8]) -> Result<[u8; 32]> { let mut okm = [0u8; 32]; Hkdf::::new(Some(salt), ikm) .expand(info, &mut okm) .or(Err(Error::HkdfInvalidLength))?; Ok(okm) } ================================================ FILE: src/transport/tcp.rs ================================================ use aead::{generic_array::GenericArray, AeadInPlace, NewAead}; use byteorder::{ByteOrder, LittleEndian}; use bytes::{Buf, BytesMut}; use chacha20poly1305::{ChaCha20Poly1305, Nonce, Tag}; use futures::{ channel::{ mpsc::{self, UnboundedReceiver, UnboundedSender}, oneshot, }, io::Error, Stream, }; use log::{debug, error}; use std::{ cmp::min, future::Future, io::{self, ErrorKind}, pin::Pin, sync::{Arc, Mutex, RwLock}, task::{Context, Poll, Waker}, }; use tokio::{ io::{AsyncRead, AsyncWrite, ReadBuf}, net::TcpStream, }; use uuid::Uuid; use crate::Result; #[derive(Debug)] pub struct StreamWrapper { incoming_receiver: UnboundedReceiver>, outgoing_sender: UnboundedSender>, incoming_waker: Arc>>, outgoing_waker: Arc>>, incoming_buf: BytesMut, } impl StreamWrapper { pub fn new( incoming_receiver: UnboundedReceiver>, outgoing_sender: UnboundedSender>, incoming_waker: Arc>>, outgoing_waker: Arc>>, ) -> StreamWrapper { StreamWrapper { incoming_receiver, outgoing_sender, incoming_waker, outgoing_waker, incoming_buf: BytesMut::new(), } } fn poll_receiver(&mut self, cx: &mut Context) -> Poll { debug!("polling incoming TCP stream receiver"); match Stream::poll_next(Pin::new(&mut self.incoming_receiver), cx) { Poll::Pending => Poll::Pending, Poll::Ready(Some(incoming)) => { let r_len = incoming.len(); self.incoming_buf.extend_from_slice(&incoming); debug!("received {} Bytes on incoming TCP stream receiver", &r_len); Poll::Ready(r_len) }, Poll::Ready(None) => { debug!("received 0 Bytes on incoming TCP stream receiver"); Poll::Ready(0) }, } } } impl AsyncRead for StreamWrapper { fn poll_read( self: Pin<&mut Self>, cx: &mut Context, buf: &mut ReadBuf, ) -> Poll> { let stream_wrapper = Pin::into_inner(self); match stream_wrapper.poll_receiver(cx) { Poll::Pending => Poll::Pending, Poll::Ready(_r_len) => { let r_len = min(buf.capacity(), stream_wrapper.incoming_buf.len()); buf.put_slice(&stream_wrapper.incoming_buf[..r_len]); stream_wrapper.incoming_buf.advance(r_len); if let Some(waker) = stream_wrapper .outgoing_waker .lock() .expect("accessing outgoing_waker") .take() { waker.wake() } if let Some(waker) = stream_wrapper .incoming_waker .lock() .expect("accessing incoming_waker") .take() { waker.wake() } Poll::Ready(Ok(())) }, } } } impl AsyncWrite for StreamWrapper { fn poll_write(self: Pin<&mut Self>, _cx: &mut Context, buf: &[u8]) -> Poll> { let stream_wrapper = Pin::into_inner(self); debug!("writing {} Bytes to outgoing TCP stream sender", buf.len()); stream_wrapper .outgoing_sender .unbounded_send(buf.to_vec()) .map_err(|_| io::Error::new(io::ErrorKind::Other, "couldn't write"))?; if let Some(waker) = stream_wrapper .outgoing_waker .lock() .expect("accessing outgoing_waker") .take() { waker.wake() } if let Some(waker) = stream_wrapper .incoming_waker .lock() .expect("accessing incoming_waker") .take() { waker.wake() } let w_len = buf.len(); debug!("wrote {} Bytes to outgoing TCP stream sender", &w_len); Poll::Ready(Ok(w_len)) } fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context) -> Poll> { // let stream_wrapper = Pin::into_inner(self); // Poll::Ready(Write::flush(stream_wrapper)) Poll::Ready(Ok(())) } fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context) -> Poll> { Poll::Ready(Ok(())) } } #[derive(Debug)] pub struct Session { pub controller_id: Uuid, pub shared_secret: [u8; 32], } #[derive(Debug)] pub struct EncryptedStream { stream: TcpStream, incoming_sender: UnboundedSender>, outgoing_receiver: UnboundedReceiver>, incoming_waker: Arc>>, outgoing_waker: Arc>>, session_receiver: oneshot::Receiver, pub controller_id: Arc>>, shared_secret: Option<[u8; 32]>, decrypt_count: u64, encrypt_count: u64, encrypted_buf: BytesMut, decrypted_buf: BytesMut, encrypted_readbuf_inner: [u8; 1042], packet_len: usize, decrypted_ready: bool, missing_data_for_decrypted_buf: bool, missing_data_for_encrypted_buf: bool, } impl EncryptedStream { pub fn new( stream: TcpStream, ) -> ( EncryptedStream, UnboundedReceiver>, UnboundedSender>, oneshot::Sender, Arc>>, Arc>>, ) { let (sender, receiver) = oneshot::channel(); let (incoming_sender, incoming_receiver) = mpsc::unbounded(); let (outgoing_sender, outgoing_receiver) = mpsc::unbounded(); let incoming_waker = Arc::new(Mutex::new(None)); let outgoing_waker = Arc::new(Mutex::new(None)); let encrypted_buf = BytesMut::with_capacity(1042); let decrypted_buf = BytesMut::with_capacity(1024); ( EncryptedStream { stream, incoming_sender, outgoing_receiver, incoming_waker: incoming_waker.clone(), outgoing_waker: outgoing_waker.clone(), session_receiver: receiver, controller_id: Arc::new(RwLock::new(None)), shared_secret: None, decrypt_count: 0, encrypt_count: 0, encrypted_buf, decrypted_buf, encrypted_readbuf_inner: [0; 1042], packet_len: 0, decrypted_ready: false, missing_data_for_decrypted_buf: false, missing_data_for_encrypted_buf: false, }, incoming_receiver, outgoing_sender, sender, incoming_waker, outgoing_waker, ) } fn read_decrypted(&mut self, buf: &mut ReadBuf) -> Poll> { debug!("reading from decrypted buffer"); if self.decrypted_ready { let r_len = min(buf.capacity(), self.packet_len - 16); buf.put_slice(&self.decrypted_buf[..r_len]); self.decrypted_buf.advance(r_len); if r_len == self.packet_len - 16 { self.decrypted_buf.clear(); self.decrypted_ready = false; } return Poll::Ready(Ok(())); } Poll::Pending } fn read_encrypted(&mut self, buf: &mut ReadBuf) -> Poll> { debug!("reading from encrypted buffer"); if self.missing_data_for_decrypted_buf { let decrypted = decrypt_chunk( &self.shared_secret.expect("missing shared secret"), &self.encrypted_buf[..2], &self.encrypted_buf[2..(self.packet_len - 14)], &self.encrypted_buf[(self.packet_len - 14)..(self.packet_len + 2)], &mut self.decrypt_count, ) .map_err(|_| io::Error::new(io::ErrorKind::Other, "decryption failed"))?; self.decrypted_buf.extend_from_slice(&decrypted); self.encrypted_buf.advance(self.packet_len + 2); self.missing_data_for_decrypted_buf = false; self.decrypted_ready = true; return self.read_decrypted(buf); } Poll::Pending } fn read_stream(&mut self, cx: &mut Context, buf: &mut ReadBuf) -> Poll> { debug!("reading from TCP stream"); if self.missing_data_for_encrypted_buf { let mut r_buf = ReadBuf::new(&mut self.encrypted_readbuf_inner); let r = AsyncRead::poll_read(Pin::new(&mut self.stream), cx, &mut r_buf)?; match r { Poll::Pending => Poll::Pending, Poll::Ready(()) => { self.encrypted_buf.extend_from_slice(r_buf.filled()); if self.encrypted_buf.len() == self.packet_len + 2 { self.missing_data_for_encrypted_buf = false; self.missing_data_for_decrypted_buf = true; return self.read_encrypted(buf); } Poll::Pending }, } } else { let mut r_buf = ReadBuf::new(&mut self.encrypted_readbuf_inner); let r = AsyncRead::poll_read(Pin::new(&mut self.stream), cx, &mut r_buf)?; match r { Poll::Pending => Poll::Pending, Poll::Ready(()) => { self.encrypted_buf.extend_from_slice(r_buf.filled()); if self.encrypted_buf.len() >= 2 { self.packet_len = LittleEndian::read_u16(&self.encrypted_buf[..2]) as usize + 16; if self.encrypted_buf.len() == self.packet_len + 2 { self.missing_data_for_encrypted_buf = false; self.missing_data_for_decrypted_buf = true; self.read_encrypted(buf) } else { self.missing_data_for_encrypted_buf = true; Poll::Pending } } else { Poll::Pending } }, } } } fn poll_outgoing(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let encrypted_stream = Pin::into_inner(self); loop { match Stream::poll_next(Pin::new(&mut encrypted_stream.outgoing_receiver), cx) { Poll::Pending => { *encrypted_stream.outgoing_waker.lock().expect("setting outgoing_waker") = Some(cx.waker().clone()); return Poll::Pending; }, Poll::Ready(Some(data)) => { debug!("writing {} Bytes to outgoing TCP stream", data.len()); match AsyncWrite::poll_write(Pin::new(encrypted_stream), cx, &data) { Poll::Pending => {}, Poll::Ready(Err(e)) => { error!("error writing to outgoing stream: {}", e); return Poll::Ready(Err(e)); }, Poll::Ready(Ok(w_len)) => { debug!("wrote {} Bytes to outgoing TCP stream", w_len); }, }; }, Poll::Ready(None) => { debug!("outgoing TCP stream ended"); return Poll::Ready(Ok(())); }, } } } fn poll_incoming(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let encrypted_stream = Pin::into_inner(self); let mut data_inner = [0; 1536]; let mut data = ReadBuf::new(&mut data_inner); loop { match AsyncRead::poll_read(Pin::new(encrypted_stream), cx, &mut data) { Poll::Pending => { *encrypted_stream.incoming_waker.lock().expect("setting incoming_waker") = Some(cx.waker().clone()); return Poll::Pending; }, Poll::Ready(Err(e)) => match e.kind() { ErrorKind::WouldBlock => { *encrypted_stream.incoming_waker.lock().expect("setting incoming_waker") = Some(cx.waker().clone()); return Poll::Pending; }, _ => { return Poll::Ready(Err(e)); }, }, Poll::Ready(Ok(())) => { let data_filled = data.filled(); if data_filled.len() == 0 { return Poll::Ready(Ok(())); } encrypted_stream .incoming_sender .unbounded_send(data_filled.to_vec()) .map_err(|_| io::Error::new(io::ErrorKind::Other, "couldn't send incoming data"))?; data.clear(); }, } } } } impl Future for EncryptedStream { type Output = std::result::Result<(), io::Error>; #[allow(unused_must_use)] fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll { let encrypted_stream = Pin::into_inner(self); EncryptedStream::poll_outgoing(Pin::new(encrypted_stream), cx)?; EncryptedStream::poll_incoming(Pin::new(encrypted_stream), cx) } } impl AsyncRead for EncryptedStream { fn poll_read( self: Pin<&mut Self>, cx: &mut Context, buf: &mut ReadBuf, ) -> Poll> { let mut encrypted_stream = Pin::into_inner(self); if encrypted_stream.shared_secret.is_none() { match encrypted_stream.session_receiver.try_recv() { Ok(Some(session)) => { *encrypted_stream.controller_id.write().expect("setting controller_id") = Some(session.controller_id); encrypted_stream.shared_secret = Some(session.shared_secret); }, _ => { return AsyncRead::poll_read(Pin::new(&mut encrypted_stream.stream), cx, buf); }, } } match encrypted_stream.read_decrypted(buf) { Poll::Ready(Ok(())) => Poll::Ready(Ok(())), Poll::Ready(Err(e)) => Poll::Ready(Err(e)), Poll::Pending => match encrypted_stream.read_encrypted(buf) { Poll::Ready(Ok(_size)) => Poll::Ready(Ok(())), Poll::Ready(Err(e)) => Poll::Ready(Err(e)), Poll::Pending => encrypted_stream.read_stream(cx, buf), }, } } } impl AsyncWrite for EncryptedStream { #[allow(unused_must_use)] fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll> { let encrypted_stream = Pin::into_inner(self); if let Some(shared_secret) = encrypted_stream.shared_secret { let mut write_buf = BytesMut::from(buf); while write_buf.len() > 1024 { let (aad, chunk, auth_tag) = encrypt_chunk(&shared_secret, &write_buf[..1024], &mut encrypted_stream.encrypt_count) .map_err(|_| io::Error::new(io::ErrorKind::Other, "encryption failed"))?; let data = [&aad[..], &chunk[..], &auth_tag[..]].concat(); AsyncWrite::poll_write(Pin::new(&mut encrypted_stream.stream), cx, &data)?; write_buf.advance(1024); } let (aad, chunk, auth_tag) = encrypt_chunk(&shared_secret, &write_buf, &mut encrypted_stream.encrypt_count) .map_err(|_| io::Error::new(io::ErrorKind::Other, "encryption failed"))?; let data = [&aad[..], &chunk[..], &auth_tag[..]].concat(); AsyncWrite::poll_write(Pin::new(&mut encrypted_stream.stream), cx, &data)?; Poll::Ready(Ok(buf.len())) } else { AsyncWrite::poll_write(Pin::new(&mut encrypted_stream.stream), cx, buf) } } fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let encrypted_stream = Pin::into_inner(self); AsyncWrite::poll_flush(Pin::new(&mut encrypted_stream.stream), cx) } fn poll_shutdown(self: Pin<&mut Self>, _cx: &mut Context) -> Poll> { Poll::Ready(Ok(())) } } fn decrypt_chunk( shared_secret: &[u8; 32], aad: &[u8], data: &[u8], auth_tag: &[u8], count: &mut u64, ) -> Result> { let read_key = compute_read_key(shared_secret)?; let aead = ChaCha20Poly1305::new(GenericArray::from_slice(&read_key)); let mut nonce = vec![0; 4]; let mut suffix = vec![0; 8]; LittleEndian::write_u64(&mut suffix, *count); nonce.extend(suffix); *count += 1; let mut buffer = Vec::new(); buffer.extend_from_slice(data); aead.decrypt_in_place_detached(Nonce::from_slice(&nonce), aad, &mut buffer, Tag::from_slice(&auth_tag))?; Ok(buffer) } fn encrypt_chunk(shared_secret: &[u8; 32], data: &[u8], count: &mut u64) -> Result<([u8; 2], Vec, [u8; 16])> { let write_key = compute_write_key(shared_secret)?; let aead = ChaCha20Poly1305::new(GenericArray::from_slice(&write_key)); let mut nonce = vec![0; 4]; let mut suffix = vec![0; 8]; LittleEndian::write_u64(&mut suffix, *count); nonce.extend(suffix); *count += 1; let mut aad = [0; 2]; LittleEndian::write_u16(&mut aad, data.len() as u16); let mut buffer = Vec::new(); buffer.extend_from_slice(data); let auth_tag = aead.encrypt_in_place_detached(Nonce::from_slice(&nonce), &aad, &mut buffer)?; Ok((aad, buffer, auth_tag.into())) } fn compute_read_key(shared_secret: &[u8; 32]) -> Result<[u8; 32]> { compute_key(shared_secret, b"Control-Write-Encryption-Key") } fn compute_write_key(shared_secret: &[u8; 32]) -> Result<[u8; 32]> { compute_key(shared_secret, b"Control-Read-Encryption-Key") } fn compute_key(shared_secret: &[u8; 32], info: &[u8]) -> Result<[u8; 32]> { super::hkdf_extract_and_expand(b"Control-Salt", shared_secret, info) }