42 lines
1.7 KiB
Rust
42 lines
1.7 KiB
Rust
use crate::commands::property_control::PropertyControlCommand;
|
|
|
|
/// Returns a PropertyControl command.
|
|
impl Into<Vec<u8>> for PropertyControlCommand {
|
|
fn into(self) -> Vec<u8> {
|
|
match self {
|
|
PropertyControlCommand::Register { property_name, data_type, read_only } => {
|
|
let mut vec = vec![];
|
|
vec.extend(property_name.into_bytes());
|
|
vec.push(data_type);
|
|
vec.push(read_only as u8);
|
|
vec
|
|
},
|
|
PropertyControlCommand::Remove { property_name } => property_name.into_bytes(),
|
|
PropertyControlCommand::Get { property_name, data } => {
|
|
let mut v = vec![];
|
|
v.extend(property_name.into_bytes());
|
|
v.extend(Into::<Vec<u8>>::into(data));
|
|
v
|
|
},
|
|
PropertyControlCommand::Set { property_name, data } => {
|
|
let mut v = vec![];
|
|
v.extend(property_name.into_bytes());
|
|
v.extend(Into::<Vec<u8>>::into(data));
|
|
v
|
|
},
|
|
PropertyControlCommand::Reset { property_name } => property_name.into_bytes(),
|
|
PropertyControlCommand::Subscribe { device_id, property_name } => {
|
|
let mut v = vec![];
|
|
v.extend(device_id.bytes);
|
|
v.extend(property_name.into_bytes());
|
|
v
|
|
},
|
|
PropertyControlCommand::Unsubscribe { device_id, property_name } => {
|
|
let mut v = vec![];
|
|
v.extend(device_id.bytes);
|
|
v.extend(property_name.into_bytes());
|
|
v
|
|
}
|
|
}
|
|
}
|
|
}
|