#![allow(
clippy::all,
clippy::pedantic,
dead_code,
unreachable_pub,
unused_imports
)]
use crate::datatypes::SemanticTagStruct;
use crate::error::ClusterError;
use crate::types::Nullable;
use matter_codec::{ContainerKind, Element, Tag, TlvReader, TlvWriter, Value};
pub const CLUSTER_ID: u32 = 0x0300;
pub const CLUSTER_REVISION: u16 = 9;
pub mod command_id {
pub const MOVE_TO_HUE: u32 = 0x00;
pub const MOVE_HUE: u32 = 0x01;
pub const STEP_HUE: u32 = 0x02;
pub const MOVE_TO_SATURATION: u32 = 0x03;
pub const MOVE_SATURATION: u32 = 0x04;
pub const STEP_SATURATION: u32 = 0x05;
pub const MOVE_TO_HUE_AND_SATURATION: u32 = 0x06;
pub const MOVE_TO_COLOR: u32 = 0x07;
pub const MOVE_COLOR: u32 = 0x08;
pub const STEP_COLOR: u32 = 0x09;
pub const MOVE_TO_COLOR_TEMPERATURE: u32 = 0x0A;
pub const ENHANCED_MOVE_TO_HUE: u32 = 0x40;
pub const ENHANCED_MOVE_HUE: u32 = 0x41;
pub const ENHANCED_STEP_HUE: u32 = 0x42;
pub const ENHANCED_MOVE_TO_HUE_AND_SATURATION: u32 = 0x43;
pub const COLOR_LOOP_SET: u32 = 0x44;
pub const STOP_MOVE_STEP: u32 = 0x47;
pub const MOVE_COLOR_TEMPERATURE: u32 = 0x4B;
pub const STEP_COLOR_TEMPERATURE: u32 = 0x4C;
}
pub mod attribute_id {
pub const CURRENT_HUE: u32 = 0x0000;
pub const CURRENT_SATURATION: u32 = 0x0001;
pub const REMAINING_TIME: u32 = 0x0002;
pub const CURRENT_X: u32 = 0x0003;
pub const CURRENT_Y: u32 = 0x0004;
pub const DRIFT_COMPENSATION: u32 = 0x0005;
pub const COMPENSATION_TEXT: u32 = 0x0006;
pub const COLOR_TEMPERATURE_MIREDS: u32 = 0x0007;
pub const COLOR_MODE: u32 = 0x0008;
pub const OPTIONS: u32 = 0x000F;
pub const NUMBER_OF_PRIMARIES: u32 = 0x0010;
pub const PRIMARY1_X: u32 = 0x0011;
pub const PRIMARY1_Y: u32 = 0x0012;
pub const PRIMARY1_INTENSITY: u32 = 0x0013;
pub const PRIMARY2_X: u32 = 0x0015;
pub const PRIMARY2_Y: u32 = 0x0016;
pub const PRIMARY2_INTENSITY: u32 = 0x0017;
pub const PRIMARY3_X: u32 = 0x0019;
pub const PRIMARY3_Y: u32 = 0x001A;
pub const PRIMARY3_INTENSITY: u32 = 0x001B;
pub const PRIMARY4_X: u32 = 0x0020;
pub const PRIMARY4_Y: u32 = 0x0021;
pub const PRIMARY4_INTENSITY: u32 = 0x0022;
pub const PRIMARY5_X: u32 = 0x0024;
pub const PRIMARY5_Y: u32 = 0x0025;
pub const PRIMARY5_INTENSITY: u32 = 0x0026;
pub const PRIMARY6_X: u32 = 0x0028;
pub const PRIMARY6_Y: u32 = 0x0029;
pub const PRIMARY6_INTENSITY: u32 = 0x002A;
pub const WHITE_POINT_X: u32 = 0x0030;
pub const WHITE_POINT_Y: u32 = 0x0031;
pub const COLOR_POINT_RX: u32 = 0x0032;
pub const COLOR_POINT_RY: u32 = 0x0033;
pub const COLOR_POINT_R_INTENSITY: u32 = 0x0034;
pub const COLOR_POINT_GX: u32 = 0x0036;
pub const COLOR_POINT_GY: u32 = 0x0037;
pub const COLOR_POINT_G_INTENSITY: u32 = 0x0038;
pub const COLOR_POINT_BX: u32 = 0x003A;
pub const COLOR_POINT_BY: u32 = 0x003B;
pub const COLOR_POINT_B_INTENSITY: u32 = 0x003C;
pub const ENHANCED_CURRENT_HUE: u32 = 0x4000;
pub const ENHANCED_COLOR_MODE: u32 = 0x4001;
pub const COLOR_LOOP_ACTIVE: u32 = 0x4002;
pub const COLOR_LOOP_DIRECTION: u32 = 0x4003;
pub const COLOR_LOOP_TIME: u32 = 0x4004;
pub const COLOR_LOOP_START_ENHANCED_HUE: u32 = 0x4005;
pub const COLOR_LOOP_STORED_ENHANCED_HUE: u32 = 0x4006;
pub const COLOR_CAPABILITIES: u32 = 0x400A;
pub const COLOR_TEMP_PHYSICAL_MIN_MIREDS: u32 = 0x400B;
pub const COLOR_TEMP_PHYSICAL_MAX_MIREDS: u32 = 0x400C;
pub const COUPLE_COLOR_TEMP_TO_LEVEL_MIN_MIREDS: u32 = 0x400D;
pub const START_UP_COLOR_TEMPERATURE_MIREDS: u32 = 0x4010;
}
bitflags::bitflags! {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Feature: u32 {
const HS = 1 << 0;
const EHUE = 1 << 1;
const CL = 1 << 2;
const XY = 1 << 3;
const CT = 1 << 4;
}
}
bitflags::bitflags! {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct ColorCapabilitiesBitmap: u16 {
const HUE_SATURATION = 1 << 0;
const ENHANCED_HUE = 1 << 1;
const COLOR_LOOP = 1 << 2;
const XY = 1 << 3;
const COLOR_TEMPERATURE = 1 << 4;
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ColorLoopActionEnum {
Deactivate,
ActivateFromColorLoopStartEnhancedHue,
ActivateFromEnhancedCurrentHue,
Unknown(u8),
}
impl ColorLoopActionEnum {
#[must_use]
pub fn from_raw(v: u8) -> Self {
match v {
0 => Self::Deactivate,
1 => Self::ActivateFromColorLoopStartEnhancedHue,
2 => Self::ActivateFromEnhancedCurrentHue,
other => Self::Unknown(other),
}
}
#[must_use]
pub fn to_raw(self) -> u8 {
match self {
Self::Deactivate => 0,
Self::ActivateFromColorLoopStartEnhancedHue => 1,
Self::ActivateFromEnhancedCurrentHue => 2,
Self::Unknown(v) => v,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ColorLoopDirectionEnum {
Decrement,
Increment,
Unknown(u8),
}
impl ColorLoopDirectionEnum {
#[must_use]
pub fn from_raw(v: u8) -> Self {
match v {
0 => Self::Decrement,
1 => Self::Increment,
other => Self::Unknown(other),
}
}
#[must_use]
pub fn to_raw(self) -> u8 {
match self {
Self::Decrement => 0,
Self::Increment => 1,
Self::Unknown(v) => v,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum ColorModeEnum {
CurrentHueAndCurrentSaturation,
CurrentXAndCurrentY,
ColorTemperatureMireds,
Unknown(u8),
}
impl ColorModeEnum {
#[must_use]
pub fn from_raw(v: u8) -> Self {
match v {
0 => Self::CurrentHueAndCurrentSaturation,
1 => Self::CurrentXAndCurrentY,
2 => Self::ColorTemperatureMireds,
other => Self::Unknown(other),
}
}
#[must_use]
pub fn to_raw(self) -> u8 {
match self {
Self::CurrentHueAndCurrentSaturation => 0,
Self::CurrentXAndCurrentY => 1,
Self::ColorTemperatureMireds => 2,
Self::Unknown(v) => v,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum DirectionEnum {
Shortest,
Longest,
Up,
Down,
Unknown(u8),
}
impl DirectionEnum {
#[must_use]
pub fn from_raw(v: u8) -> Self {
match v {
0 => Self::Shortest,
1 => Self::Longest,
2 => Self::Up,
3 => Self::Down,
other => Self::Unknown(other),
}
}
#[must_use]
pub fn to_raw(self) -> u8 {
match self {
Self::Shortest => 0,
Self::Longest => 1,
Self::Up => 2,
Self::Down => 3,
Self::Unknown(v) => v,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum DriftCompensationEnum {
None,
OtherOrUnknown,
TemperatureMonitoring,
OpticalLuminanceMonitoringAndFeedback,
OpticalColorMonitoringAndFeedback,
Unknown(u8),
}
impl DriftCompensationEnum {
#[must_use]
pub fn from_raw(v: u8) -> Self {
match v {
0 => Self::None,
1 => Self::OtherOrUnknown,
2 => Self::TemperatureMonitoring,
3 => Self::OpticalLuminanceMonitoringAndFeedback,
4 => Self::OpticalColorMonitoringAndFeedback,
other => Self::Unknown(other),
}
}
#[must_use]
pub fn to_raw(self) -> u8 {
match self {
Self::None => 0,
Self::OtherOrUnknown => 1,
Self::TemperatureMonitoring => 2,
Self::OpticalLuminanceMonitoringAndFeedback => 3,
Self::OpticalColorMonitoringAndFeedback => 4,
Self::Unknown(v) => v,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum EnhancedColorModeEnum {
CurrentHueAndCurrentSaturation,
CurrentXAndCurrentY,
ColorTemperatureMireds,
EnhancedCurrentHueAndCurrentSaturation,
Unknown(u8),
}
impl EnhancedColorModeEnum {
#[must_use]
pub fn from_raw(v: u8) -> Self {
match v {
0 => Self::CurrentHueAndCurrentSaturation,
1 => Self::CurrentXAndCurrentY,
2 => Self::ColorTemperatureMireds,
3 => Self::EnhancedCurrentHueAndCurrentSaturation,
other => Self::Unknown(other),
}
}
#[must_use]
pub fn to_raw(self) -> u8 {
match self {
Self::CurrentHueAndCurrentSaturation => 0,
Self::CurrentXAndCurrentY => 1,
Self::ColorTemperatureMireds => 2,
Self::EnhancedCurrentHueAndCurrentSaturation => 3,
Self::Unknown(v) => v,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum MoveModeEnum {
Stop,
Up,
Down,
Unknown(u8),
}
impl MoveModeEnum {
#[must_use]
pub fn from_raw(v: u8) -> Self {
match v {
0 => Self::Stop,
1 => Self::Up,
3 => Self::Down,
other => Self::Unknown(other),
}
}
#[must_use]
pub fn to_raw(self) -> u8 {
match self {
Self::Stop => 0,
Self::Up => 1,
Self::Down => 3,
Self::Unknown(v) => v,
}
}
}
bitflags::bitflags! {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct OptionsBitmap: u8 {
const EXECUTE_IF_OFF = 1 << 0;
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum StepModeEnum {
Up,
Down,
Unknown(u8),
}
impl StepModeEnum {
#[must_use]
pub fn from_raw(v: u8) -> Self {
match v {
1 => Self::Up,
3 => Self::Down,
other => Self::Unknown(other),
}
}
#[must_use]
pub fn to_raw(self) -> u8 {
match self {
Self::Up => 1,
Self::Down => 3,
Self::Unknown(v) => v,
}
}
}
bitflags::bitflags! {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct UpdateFlagsBitmap: u8 {
const UPDATE_ACTION = 1 << 0;
const UPDATE_DIRECTION = 1 << 1;
const UPDATE_TIME = 1 << 2;
const UPDATE_START_HUE = 1 << 3;
}
}
pub fn decode_current_hue(tlv: &[u8]) -> Result<u8, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("CurrentHue"))?),
_ => Err(ClusterError::UnexpectedType {
context: "CurrentHue",
}),
}
}
pub fn decode_current_saturation(tlv: &[u8]) -> Result<u8, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("CurrentSaturation"))?),
_ => Err(ClusterError::UnexpectedType {
context: "CurrentSaturation",
}),
}
}
pub fn decode_remaining_time(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("RemainingTime"))?),
_ => Err(ClusterError::UnexpectedType {
context: "RemainingTime",
}),
}
}
pub fn decode_current_x(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("CurrentX"))?),
_ => Err(ClusterError::UnexpectedType {
context: "CurrentX",
}),
}
}
pub fn decode_current_y(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("CurrentY"))?),
_ => Err(ClusterError::UnexpectedType {
context: "CurrentY",
}),
}
}
pub fn decode_drift_compensation(tlv: &[u8]) -> Result<DriftCompensationEnum, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(DriftCompensationEnum::from_raw(
u8::try_from(v).map_err(|_| ClusterError::InvalidLength("DriftCompensation"))?,
)),
_ => Err(ClusterError::UnexpectedType {
context: "DriftCompensation",
}),
}
}
pub fn decode_compensation_text(tlv: &[u8]) -> Result<String, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Utf8(v),
..
}) => Ok(v),
_ => Err(ClusterError::UnexpectedType {
context: "CompensationText",
}),
}
}
pub fn decode_color_temperature_mireds(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => {
Ok(u16::try_from(v)
.map_err(|_| ClusterError::InvalidLength("ColorTemperatureMireds"))?)
}
_ => Err(ClusterError::UnexpectedType {
context: "ColorTemperatureMireds",
}),
}
}
pub fn decode_color_mode(tlv: &[u8]) -> Result<ColorModeEnum, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(ColorModeEnum::from_raw(
u8::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorMode"))?,
)),
_ => Err(ClusterError::UnexpectedType {
context: "ColorMode",
}),
}
}
pub fn decode_options(tlv: &[u8]) -> Result<OptionsBitmap, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(OptionsBitmap::from_bits_retain(
u8::try_from(v).map_err(|_| ClusterError::InvalidLength("Options"))?,
)),
_ => Err(ClusterError::UnexpectedType { context: "Options" }),
}
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_options(value: OptionsBitmap) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.put_uint(Tag::Anonymous, u64::from(value.bits()))
.expect("infallible: vec writer");
buf
}
pub fn decode_number_of_primaries(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => {
Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("NumberOfPrimaries")
})?))
}
_ => Err(ClusterError::UnexpectedType {
context: "NumberOfPrimaries",
}),
}
}
pub fn decode_primary1_x(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary1X"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary1X",
}),
}
}
pub fn decode_primary1_y(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary1Y"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary1Y",
}),
}
}
pub fn decode_primary1_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => {
Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("Primary1Intensity")
})?))
}
_ => Err(ClusterError::UnexpectedType {
context: "Primary1Intensity",
}),
}
}
pub fn decode_primary2_x(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary2X"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary2X",
}),
}
}
pub fn decode_primary2_y(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary2Y"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary2Y",
}),
}
}
pub fn decode_primary2_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => {
Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("Primary2Intensity")
})?))
}
_ => Err(ClusterError::UnexpectedType {
context: "Primary2Intensity",
}),
}
}
pub fn decode_primary3_x(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary3X"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary3X",
}),
}
}
pub fn decode_primary3_y(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary3Y"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary3Y",
}),
}
}
pub fn decode_primary3_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => {
Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("Primary3Intensity")
})?))
}
_ => Err(ClusterError::UnexpectedType {
context: "Primary3Intensity",
}),
}
}
pub fn decode_primary4_x(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary4X"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary4X",
}),
}
}
pub fn decode_primary4_y(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary4Y"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary4Y",
}),
}
}
pub fn decode_primary4_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => {
Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("Primary4Intensity")
})?))
}
_ => Err(ClusterError::UnexpectedType {
context: "Primary4Intensity",
}),
}
}
pub fn decode_primary5_x(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary5X"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary5X",
}),
}
}
pub fn decode_primary5_y(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary5Y"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary5Y",
}),
}
}
pub fn decode_primary5_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => {
Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("Primary5Intensity")
})?))
}
_ => Err(ClusterError::UnexpectedType {
context: "Primary5Intensity",
}),
}
}
pub fn decode_primary6_x(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary6X"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary6X",
}),
}
}
pub fn decode_primary6_y(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("Primary6Y"))?),
_ => Err(ClusterError::UnexpectedType {
context: "Primary6Y",
}),
}
}
pub fn decode_primary6_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => {
Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("Primary6Intensity")
})?))
}
_ => Err(ClusterError::UnexpectedType {
context: "Primary6Intensity",
}),
}
}
pub fn decode_white_point_x(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("WhitePointX"))?),
_ => Err(ClusterError::UnexpectedType {
context: "WhitePointX",
}),
}
}
pub fn decode_white_point_y(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("WhitePointY"))?),
_ => Err(ClusterError::UnexpectedType {
context: "WhitePointY",
}),
}
}
pub fn decode_color_point_rx(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorPointRx"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointRx",
}),
}
}
pub fn decode_color_point_ry(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorPointRy"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointRy",
}),
}
}
pub fn decode_color_point_r_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("ColorPointRIntensity")
})?)),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointRIntensity",
}),
}
}
pub fn decode_color_point_gx(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorPointGx"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointGx",
}),
}
}
pub fn decode_color_point_gy(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorPointGy"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointGy",
}),
}
}
pub fn decode_color_point_g_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("ColorPointGIntensity")
})?)),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointGIntensity",
}),
}
}
pub fn decode_color_point_bx(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorPointBx"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointBx",
}),
}
}
pub fn decode_color_point_by(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorPointBy"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointBy",
}),
}
}
pub fn decode_color_point_b_intensity(tlv: &[u8]) -> Result<Nullable<u8>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(Nullable::Value(u8::try_from(v).map_err(|_| {
ClusterError::InvalidLength("ColorPointBIntensity")
})?)),
_ => Err(ClusterError::UnexpectedType {
context: "ColorPointBIntensity",
}),
}
}
pub fn decode_enhanced_current_hue(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("EnhancedCurrentHue"))?),
_ => Err(ClusterError::UnexpectedType {
context: "EnhancedCurrentHue",
}),
}
}
pub fn decode_enhanced_color_mode(tlv: &[u8]) -> Result<EnhancedColorModeEnum, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(EnhancedColorModeEnum::from_raw(
u8::try_from(v).map_err(|_| ClusterError::InvalidLength("EnhancedColorMode"))?,
)),
_ => Err(ClusterError::UnexpectedType {
context: "EnhancedColorMode",
}),
}
}
pub fn decode_color_loop_active(tlv: &[u8]) -> Result<u8, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorLoopActive"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorLoopActive",
}),
}
}
pub fn decode_color_loop_direction(tlv: &[u8]) -> Result<ColorLoopDirectionEnum, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(ColorLoopDirectionEnum::from_raw(u8::try_from(v).map_err(
|_| ClusterError::InvalidLength("ColorLoopDirection"),
)?)),
_ => Err(ClusterError::UnexpectedType {
context: "ColorLoopDirection",
}),
}
}
pub fn decode_color_loop_time(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorLoopTime"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorLoopTime",
}),
}
}
pub fn decode_color_loop_start_enhanced_hue(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v)
.map_err(|_| ClusterError::InvalidLength("ColorLoopStartEnhancedHue"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorLoopStartEnhancedHue",
}),
}
}
pub fn decode_color_loop_stored_enhanced_hue(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v)
.map_err(|_| ClusterError::InvalidLength("ColorLoopStoredEnhancedHue"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorLoopStoredEnhancedHue",
}),
}
}
pub fn decode_color_capabilities(tlv: &[u8]) -> Result<ColorCapabilitiesBitmap, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(ColorCapabilitiesBitmap::from_bits_retain(
u16::try_from(v).map_err(|_| ClusterError::InvalidLength("ColorCapabilities"))?,
)),
_ => Err(ClusterError::UnexpectedType {
context: "ColorCapabilities",
}),
}
}
pub fn decode_color_temp_physical_min_mireds(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v)
.map_err(|_| ClusterError::InvalidLength("ColorTempPhysicalMinMireds"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorTempPhysicalMinMireds",
}),
}
}
pub fn decode_color_temp_physical_max_mireds(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v)
.map_err(|_| ClusterError::InvalidLength("ColorTempPhysicalMaxMireds"))?),
_ => Err(ClusterError::UnexpectedType {
context: "ColorTempPhysicalMaxMireds",
}),
}
}
pub fn decode_couple_color_temp_to_level_min_mireds(tlv: &[u8]) -> Result<u16, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(u16::try_from(v)
.map_err(|_| ClusterError::InvalidLength("CoupleColorTempToLevelMinMireds"))?),
_ => Err(ClusterError::UnexpectedType {
context: "CoupleColorTempToLevelMinMireds",
}),
}
}
pub fn decode_start_up_color_temperature_mireds(tlv: &[u8]) -> Result<Nullable<u16>, ClusterError> {
let mut r = TlvReader::new(tlv);
match r.next()? {
Some(Element::Scalar {
value: Value::Null, ..
}) => Ok(Nullable::Null),
Some(Element::Scalar {
value: Value::Uint(v),
..
}) => Ok(Nullable::Value(u16::try_from(v).map_err(|_| {
ClusterError::InvalidLength("StartUpColorTemperatureMireds")
})?)),
_ => Err(ClusterError::UnexpectedType {
context: "StartUpColorTemperatureMireds",
}),
}
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_start_up_color_temperature_mireds(value: Nullable<u16>) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
match value {
Nullable::Null => w.put_null(Tag::Anonymous).expect("infallible: vec writer"),
Nullable::Value(value) => {
w.put_uint(Tag::Anonymous, u64::from(value))
.expect("infallible: vec writer");
}
}
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_to_hue(
hue: u8,
direction: DirectionEnum,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(hue))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(direction.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_hue(
move_mode: MoveModeEnum,
rate: u8,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(move_mode.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(rate))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_step_hue(
step_mode: StepModeEnum,
step_size: u8,
transition_time: u8,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(step_mode.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(step_size))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_to_saturation(
saturation: u8,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(saturation))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_saturation(
move_mode: MoveModeEnum,
rate: u8,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(move_mode.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(rate))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_step_saturation(
step_mode: StepModeEnum,
step_size: u8,
transition_time: u8,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(step_mode.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(step_size))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_to_hue_and_saturation(
hue: u8,
saturation: u8,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(hue))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(saturation))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_to_color(
color_x: u16,
color_y: u16,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(color_x))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(color_y))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_color(
rate_x: i16,
rate_y: i16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_int(Tag::Context(0), i64::from(rate_x))
.expect("infallible: vec writer");
w.put_int(Tag::Context(1), i64::from(rate_y))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_step_color(
step_x: i16,
step_y: i16,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_int(Tag::Context(0), i64::from(step_x))
.expect("infallible: vec writer");
w.put_int(Tag::Context(1), i64::from(step_y))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_to_color_temperature(
color_temperature_mireds: u16,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(color_temperature_mireds))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_enhanced_move_to_hue(
enhanced_hue: u16,
direction: DirectionEnum,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(enhanced_hue))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(direction.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_enhanced_move_hue(
move_mode: MoveModeEnum,
rate: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(move_mode.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(rate))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_enhanced_step_hue(
step_mode: StepModeEnum,
step_size: u16,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(step_mode.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(step_size))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_enhanced_move_to_hue_and_saturation(
enhanced_hue: u16,
saturation: u8,
transition_time: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(enhanced_hue))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(saturation))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_color_loop_set(
update_flags: UpdateFlagsBitmap,
action: ColorLoopActionEnum,
direction: ColorLoopDirectionEnum,
time: u16,
start_hue: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(update_flags.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(action.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(direction.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(start_hue))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(5), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(6), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_stop_move_step(
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_move_color_temperature(
move_mode: MoveModeEnum,
rate: u16,
color_temperature_minimum_mireds: u16,
color_temperature_maximum_mireds: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(move_mode.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(rate))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(color_temperature_minimum_mireds))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(color_temperature_maximum_mireds))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(5), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}
#[must_use]
#[allow(clippy::expect_used, clippy::missing_panics_doc)] pub fn encode_step_color_temperature(
step_mode: StepModeEnum,
step_size: u16,
transition_time: u16,
color_temperature_minimum_mireds: u16,
color_temperature_maximum_mireds: u16,
options_mask: OptionsBitmap,
options_override: OptionsBitmap,
) -> Vec<u8> {
let mut buf = Vec::new();
let mut w = TlvWriter::new(&mut buf);
w.start_structure(Tag::Anonymous)
.expect("infallible: vec writer");
w.put_uint(Tag::Context(0), u64::from(step_mode.to_raw()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(1), u64::from(step_size))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(2), u64::from(transition_time))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(3), u64::from(color_temperature_minimum_mireds))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(4), u64::from(color_temperature_maximum_mireds))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(5), u64::from(options_mask.bits()))
.expect("infallible: vec writer");
w.put_uint(Tag::Context(6), u64::from(options_override.bits()))
.expect("infallible: vec writer");
w.end_container().expect("infallible: vec writer");
buf
}