31 lines
1 KiB
Rust
31 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 } => {
|
|
vec![
|
|
device_id.bytes[0],
|
|
device_id.bytes[1],
|
|
device_id.bytes[2],
|
|
device_id.bytes[3],
|
|
]
|
|
}
|
|
NodeManagementCommand::RemoveNode => vec![],
|
|
NodeManagementCommand::AcknowledgePackets { packet_ids } =>
|
|
packet_ids.iter().map(|i| i.bytes).flatten().collect(),
|
|
|
|
NodeManagementCommand::Error {
|
|
error_code,
|
|
metadata,
|
|
} => {
|
|
let mut vec = vec![];
|
|
vec.push(error_code);
|
|
vec.extend(metadata);
|
|
vec
|
|
}
|
|
}
|
|
}
|
|
}
|