[−][src]Struct homie_controller::Property
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
impl Property
[src]
pub fn has_required_attributes(&self) -> bool
[src]
Returns whether all the required attributes of the property are filled in.
pub fn value<T: Value>(&self) -> Result<T, ValueError>
[src]
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.
pub fn color_format(&self) -> Result<ColorFormat, ValueError>
[src]
If the datatype of the property is Color
, returns the color format.
pub fn enum_values(&self) -> Result<Vec<&str>, ValueError>
[src]
If the datatype of the property is Enum
, gets the possible values of the enum.
pub fn range<T: Value + Copy>(&self) -> Result<RangeInclusive<T>, ValueError>
[src]
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
impl Clone for Property
[src]
impl Debug for Property
[src]
impl Eq for Property
[src]
impl PartialEq<Property> for Property
[src]
impl StructuralEq for Property
[src]
impl StructuralPartialEq for Property
[src]
Auto Trait Implementations
impl RefUnwindSafe for Property
[src]
impl Send for Property
[src]
impl Sync for Property
[src]
impl Unpin for Property
[src]
impl UnwindSafe for Property
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,