From a62fd81bf27fbe5e14b521be4f01b9fb877da281 Mon Sep 17 00:00:00 2001 From: Raine Date: Mon, 4 Dec 2023 14:02:53 +0100 Subject: [PATCH] fix: up to spec --- domo_proto/src/commands/node_management/mod.rs | 2 +- domo_proto/src/commands/property_control/mod.rs | 2 +- domo_proto/src/commands/raw_data_transmission/mod.rs | 2 +- domo_proto/src/data_types/vec.rs | 3 +-- domo_proto/src/packet/mod.rs | 4 ++-- domo_proto/src/packet/packet_data.rs | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/domo_proto/src/commands/node_management/mod.rs b/domo_proto/src/commands/node_management/mod.rs index 668e24a..fb32d98 100644 --- a/domo_proto/src/commands/node_management/mod.rs +++ b/domo_proto/src/commands/node_management/mod.rs @@ -7,7 +7,7 @@ use crate::packet::packet_data::PacketData; pub mod vec; pub mod errors; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum NodeManagementCommand { Ping, RegisterNode { device_id: Identifier }, diff --git a/domo_proto/src/commands/property_control/mod.rs b/domo_proto/src/commands/property_control/mod.rs index 270b32c..69d7be5 100644 --- a/domo_proto/src/commands/property_control/mod.rs +++ b/domo_proto/src/commands/property_control/mod.rs @@ -8,7 +8,7 @@ use std::io; pub mod vec; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum PropertyControlCommand { Register { property_name: String, diff --git a/domo_proto/src/commands/raw_data_transmission/mod.rs b/domo_proto/src/commands/raw_data_transmission/mod.rs index 22c65f8..8ff1d2e 100644 --- a/domo_proto/src/commands/raw_data_transmission/mod.rs +++ b/domo_proto/src/commands/raw_data_transmission/mod.rs @@ -7,7 +7,7 @@ use crate::{ pub mod vec; -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum RawDataTransmission { SetupTransmission { /// The total size of the data being sent. diff --git a/domo_proto/src/data_types/vec.rs b/domo_proto/src/data_types/vec.rs index dad217e..bff2846 100644 --- a/domo_proto/src/data_types/vec.rs +++ b/domo_proto/src/data_types/vec.rs @@ -1,7 +1,6 @@ use std::io; use crate::data_types::{DataType, get_data_types}; -use crate::identifier::{Identifier, self}; -use crate::prelude::as_u64_be; +use crate::identifier::Identifier; impl Into> for DataType { fn into(self) -> Vec { diff --git a/domo_proto/src/packet/mod.rs b/domo_proto/src/packet/mod.rs index 060dc4b..2a39421 100644 --- a/domo_proto/src/packet/mod.rs +++ b/domo_proto/src/packet/mod.rs @@ -17,7 +17,7 @@ pub const FULL_PACKET_SIZE: usize = 65559; pub const BASE_PACKET_SIZE: usize = 65555; /// The abstraction for all DomoProto packets. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Packet { pub dest: Identifier, pub src: Identifier, @@ -40,7 +40,7 @@ impl Default for Packet { command: 0x00, packet_id: Identifier::random(), reply_to: Identifier::default(), - data: PacketData::Unknown(vec![]) + data: PacketData::NodeManagement(crate::commands::node_management::NodeManagementCommand::Ping) } } } diff --git a/domo_proto/src/packet/packet_data.rs b/domo_proto/src/packet/packet_data.rs index f595088..0c47bf7 100644 --- a/domo_proto/src/packet/packet_data.rs +++ b/domo_proto/src/packet/packet_data.rs @@ -5,7 +5,7 @@ use crate::commands::raw_data_transmission::RawDataTransmission; use crate::packet::raw_packet::RawPacket; /// Abstraction used for interpreting the data in a packet. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum PacketData { NodeManagement(NodeManagementCommand), PropertyControl(PropertyControlCommand),