From 96fea89adc84a02afb0219ecb50e1f402153fa37 Mon Sep 17 00:00:00 2001 From: clerie Date: Wed, 1 Jan 2025 16:30:17 +0100 Subject: [PATCH] Make constant uppercase --- src/improv.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/improv.rs b/src/improv.rs index e9ca91d..7670211 100644 --- a/src/improv.rs +++ b/src/improv.rs @@ -157,7 +157,7 @@ pub fn calculate_checksum(data: &[u8]) -> u8 { } pub trait ImprovDataPacketType { - const packet_type: PacketType; + const PACKET_TYPE: PacketType; } pub trait ImprovDataToPacket: ImprovDataPacketType { @@ -166,7 +166,7 @@ pub trait ImprovDataToPacket: ImprovDataPacketType { fn to_raw_packet(&self) -> RawPacket { return RawPacket { version: IMPROV_VERSION, - r#type: Self::packet_type, + r#type: Self::PACKET_TYPE, data: self.to_bytes().to_vec(), } @@ -281,7 +281,7 @@ pub struct CurrentStatePacket { } impl ImprovDataPacketType for CurrentStatePacket { - const packet_type: PacketType = PacketType::CurrentState; + const PACKET_TYPE: PacketType = PacketType::CurrentState; } impl ImprovDataToPacket for CurrentStatePacket { @@ -296,7 +296,7 @@ impl ImprovDataFromPacket for CurrentStatePacket { type Error = Error; fn try_from_raw_packet(raw_packet: &RawPacket) -> Result{ - if raw_packet.r#type != Self::packet_type { + if raw_packet.r#type != Self::PACKET_TYPE { return Err(anyhow!("Packet is not CurrentStatePacket")); } @@ -311,14 +311,14 @@ pub struct ErrorStatePacket { } impl ImprovDataPacketType for ErrorStatePacket { - const packet_type: PacketType = PacketType::ErrorState; + const PACKET_TYPE: PacketType = PacketType::ErrorState; } impl ImprovDataFromPacket for ErrorStatePacket { type Error = Error; fn try_from_raw_packet(raw_packet: &RawPacket) -> Result{ - if raw_packet.r#type != Self::packet_type { + if raw_packet.r#type != Self::PACKET_TYPE { return Err(anyhow!("Packet is not ErrorState")); } @@ -334,7 +334,7 @@ pub struct SendWiFiSettingsPacket { } impl ImprovDataPacketType for SendWiFiSettingsPacket { - const packet_type: PacketType = PacketType::RPCCommand; + const PACKET_TYPE: PacketType = PacketType::RPCCommand; } impl ImprovDataToPacket for SendWiFiSettingsPacket { @@ -360,7 +360,7 @@ pub struct RequestCurrentStatePacket { } impl ImprovDataPacketType for RequestCurrentStatePacket { - const packet_type: PacketType = PacketType::RPCCommand; + const PACKET_TYPE: PacketType = PacketType::RPCCommand; } impl ImprovDataToPacket for RequestCurrentStatePacket { @@ -376,7 +376,7 @@ pub struct RequestDeviceInformationPacket { } impl ImprovDataPacketType for RequestDeviceInformationPacket { - const packet_type: PacketType = PacketType::RPCCommand; + const PACKET_TYPE: PacketType = PacketType::RPCCommand; } impl ImprovDataToPacket for RequestDeviceInformationPacket { @@ -392,7 +392,7 @@ pub struct RequestScannedWiFiNetworksPacket { } impl ImprovDataPacketType for RequestScannedWiFiNetworksPacket { - const packet_type: PacketType = PacketType::RPCCommand; + const PACKET_TYPE: PacketType = PacketType::RPCCommand; } impl ImprovDataToPacket for RequestScannedWiFiNetworksPacket { @@ -410,14 +410,14 @@ pub struct RPCResultPacket { } impl ImprovDataPacketType for RPCResultPacket { - const packet_type: PacketType = PacketType::RPCResult; + const PACKET_TYPE: PacketType = PacketType::RPCResult; } impl ImprovDataFromPacket for RPCResultPacket { type Error = Error; fn try_from_raw_packet(raw_packet: &RawPacket) -> Result{ - if raw_packet.r#type != Self::packet_type { + if raw_packet.r#type != Self::PACKET_TYPE { return Err(anyhow!("Packet is not RPCResult")); }