pub struct Property {
    pub id: String,
    pub name: Option<String>,
    pub datatype: Option<Datatype>,
    pub settable: bool,
    pub retained: bool,
    pub unit: Option<String>,
    pub format: Option<String>,
    pub value: Option<String>,
}
Expand description

A property of a Homie node.

The id, name and datatype are required, but might not be available immediately when the property is first discovered. The other attributes are optional.

Fields

id: String

The subtopic ID of the property. This is unique per node, and should follow the Homie ID format.

name: Option<String>

The human-readable name of the property. This is a required attribute, but might not be available as soon as the property is first discovered.

datatype: Option<Datatype>

The data type of the property. This is a required attribute, but might not be available as soon as the property is first discovered.

settable: bool

Whether the property can be set by the Homie controller. This should be true for properties like the brightness or power state of a light, and false for things like the temperature reading of a sensor. It is false by default.

retained: bool

Whether the property value is retained by the MQTT broker. This is true by default.

unit: Option<String>

The unit of the property, if any. This may be one of the recommended units, or any other custom unit.

format: Option<String>

The format of the property, if any. This should be specified if the datatype is Enum or Color, and may be specified if the datatype is Integer or Float.

This field holds the raw string received from the device. Use color_format, enum_values or range to parse it according to the datatype of the property.

value: Option<String>

The current value of the property, if known. This may change frequently.

This field holds the raw string received from the device. Use value to parse it according to the datatype of the property.

Implementations

Returns whether all the required attributes of the property are filled in.

The value of the property, parsed as the appropriate Homie Value type. This will return WrongDatatype if you try to parse it as a type which doesn’t match the datatype declared by the property.

If the datatype of the property is Color, returns the color format.

If the datatype of the property is Enum, gets the possible values of the enum.

If the dataype of the property is Integer or Float, gets the allowed range of values (if any is declared by the device).

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.