hc-homie5-macros

Crates.iohc-homie5-macros
lib.rshc-homie5-macros
version
sourcesrc
created_at2025-02-08 19:03:48.461561+00
updated_at2025-02-08 19:06:31.883268+00
descriptionHelper crate for hc-homie5 to implement procedural macros for homie device creation.
homepage
repositoryhttps://github.com/homie-homecontrol/hc-homie5-macros
max_upload_size
id1548311
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
schaze (schaze)

documentation

README

hc-homie5-proc

hc-homie5-proc is a helper crate for hc-homie5 that provides procedural macros to simplify the creation of Homie-compliant devices in Rust.

Overview

This crate offers a procedural macro, homie_device, which automatically adds the necessary fields and implements the HomieDeviceCore trait for structs representing Homie devices.

Usage

You will most likely never use this create directly. It will be installed alongside hc-homie5 and reexported from there.

Example

use hc_homie5_proc::homie_device;
use hc_homie5::{HomieDeviceCore, HomieMQTTClient};
use homie5::{
    device_description::HomieDeviceDescription, Homie5DeviceProtocol, HomieDeviceStatus,
    HomieDomain, HomieID, DeviceRef,
};

#[homie_device]
pub struct MyDevice {
    some_field: String,
}

What the Macro Does

Applying #[homie_device] to a struct:

  • Ensures the struct has named fields.
  • Adds the following fields automatically:
    • device_ref: DeviceRef
    • status: HomieDeviceStatus
    • device_desc: HomieDeviceDescription
    • homie_proto: Homie5DeviceProtocol
    • homie_client: HomieMQTTClient
  • Implements the HomieDeviceCore trait for the struct with default implementations for required methods.

Features

  • Reduces boilerplate code for Homie-compliant devices.
  • Ensures all required fields and trait implementations are correctly added.
  • Compatible with hc-homie5 for seamless MQTT-based home automation device creation.

License

This project is licensed under the MIT License.

Commit count: 3

cargo fmt