26 lines
1 KiB
Rust
26 lines
1 KiB
Rust
use crate::commands::node_management::NodeManagementCommand;
|
|
|
|
/// Returns a NodeManagement command.
|
|
impl Into<Vec<u8>> for NodeManagementCommand {
|
|
fn into(self) -> Vec<u8> {
|
|
match self {
|
|
NodeManagementCommand::Ping => vec![],
|
|
NodeManagementCommand::RegisterNode { device_id } => device_id.bytes.to_vec(),
|
|
NodeManagementCommand::RemoveNode => vec![],
|
|
NodeManagementCommand::RegisterProperty { 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
|
|
},
|
|
NodeManagementCommand::RemoveProperty { property_name } => property_name.into_bytes(),
|
|
NodeManagementCommand::Error { error_code, metadata } => {
|
|
let mut vec = vec![];
|
|
vec.push(error_code);
|
|
vec.extend(metadata);
|
|
vec
|
|
}
|
|
}
|
|
}
|
|
}
|