pub enum Value {
Show 13 variants
NoData,
Bool(u8),
Bits(DataType, u64),
Uint(DataType, u64),
Int(DataType, i64),
Enum(DataType, u16),
Float(DataType, f64),
Octets(DataType, Option<Vec<u8>>),
Chars(DataType, Option<String>),
List(DataType, DataType, Option<Vec<Value>>),
Struct(Option<Vec<Value>>),
Ieee(Ieee),
Key(Key),
}Expand description
A decoded ZCL value.
Variants§
NoData
No data.
Bool(u8)
A boolean, as sent: 0 false, 1 true, 0xFF invalid.
Bits(DataType, u64)
Raw data (dataN) or a bitmap (mapN).
Uint(DataType, u64)
An unsigned integer, or a time, date or id type.
Int(DataType, i64)
A signed integer.
Enum(DataType, u16)
An enumeration.
Float(DataType, f64)
A floating-point value (half, single or double precision).
Octets(DataType, Option<Vec<u8>>)
An octet string; None is the invalid (0xFF / 0xFFFF length) value.
Chars(DataType, Option<String>)
A character string; None is the invalid value. Bytes that are not
UTF-8 are replaced.
List(DataType, DataType, Option<Vec<Value>>)
An array, set or bag: container type, element type, elements.
Struct(Option<Vec<Value>>)
A structure.
Ieee(Ieee)
An IEEE address.
Key(Key)
A 128-bit key.
Implementations§
Source§impl Value
impl Value
Sourcepub fn decode(t: DataType, r: &mut Reader<'_>) -> Result<Value, ValueError>
pub fn decode(t: DataType, r: &mut Reader<'_>) -> Result<Value, ValueError>
Decode a value of type t (the type id has already been read).
Sourcepub fn decode_typed(r: &mut Reader<'_>) -> Result<Value, ValueError>
pub fn decode_typed(r: &mut Reader<'_>) -> Result<Value, ValueError>
Decode a type id followed by a value.
Sourcepub fn encode_typed(&self, w: &mut Vec<u8>)
pub fn encode_typed(&self, w: &mut Vec<u8>)
Encode the type id and the value.
Sourcepub fn is_invalid(&self) -> bool
pub fn is_invalid(&self) -> bool
True for the type’s “invalid” (non-value) encoding: a sensor that has no reading reports this.
Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
The value as a number, unless it is invalid or not numeric.