Skip to main content

Value

Enum Value 

Source
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

Source

pub fn u8(v: u8) -> Value

An unsigned 8-bit integer.

Source

pub fn u16(v: u16) -> Value

An unsigned 16-bit integer.

Source

pub fn u32(v: u32) -> Value

An unsigned 32-bit integer.

Source

pub fn i16(v: i16) -> Value

A signed 16-bit integer.

Source

pub fn bool(v: bool) -> Value

A boolean.

Source

pub fn enum8(v: u8) -> Value

An 8-bit enumeration.

Source

pub fn enum16(v: u16) -> Value

A 16-bit enumeration.

Source

pub fn map8(v: u8) -> Value

An 8-bit bitmap.

Source

pub fn map16(v: u16) -> Value

A 16-bit bitmap.

Source

pub fn string(v: &str) -> Value

A character string.

Source

pub fn data_type(&self) -> DataType

The value’s data type.

Source

pub fn decode(t: DataType, r: &mut Reader<'_>) -> Result<Value, ValueError>

Decode a value of type t (the type id has already been read).

Source

pub fn decode_typed(r: &mut Reader<'_>) -> Result<Value, ValueError>

Decode a type id followed by a value.

Source

pub fn encode(&self, w: &mut Vec<u8>)

Encode the value without its type id.

Source

pub fn encode_typed(&self, w: &mut Vec<u8>)

Encode the type id and the value.

Source

pub fn is_invalid(&self) -> bool

True for the type’s “invalid” (non-value) encoding: a sensor that has no reading reports this.

Source

pub fn as_f64(&self) -> Option<f64>

The value as a number, unless it is invalid or not numeric.

Source

pub fn as_u64(&self) -> Option<u64>

The value as an unsigned integer, unless invalid or not integral.

Source

pub fn as_bool(&self) -> Option<bool>

The value as a boolean.

Source

pub fn as_str(&self) -> Option<&str>

The value as text, for character strings.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Value

Available on crate feature serde only.
Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.