Make constant uppercase
This commit is contained in:
parent
b28183fd53
commit
96fea89adc
@ -157,7 +157,7 @@ pub fn calculate_checksum(data: &[u8]) -> u8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub trait ImprovDataPacketType {
|
pub trait ImprovDataPacketType {
|
||||||
const packet_type: PacketType;
|
const PACKET_TYPE: PacketType;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ImprovDataToPacket: ImprovDataPacketType {
|
pub trait ImprovDataToPacket: ImprovDataPacketType {
|
||||||
@ -166,7 +166,7 @@ pub trait ImprovDataToPacket: ImprovDataPacketType {
|
|||||||
fn to_raw_packet(&self) -> RawPacket {
|
fn to_raw_packet(&self) -> RawPacket {
|
||||||
return RawPacket {
|
return RawPacket {
|
||||||
version: IMPROV_VERSION,
|
version: IMPROV_VERSION,
|
||||||
r#type: Self::packet_type,
|
r#type: Self::PACKET_TYPE,
|
||||||
data: self.to_bytes().to_vec(),
|
data: self.to_bytes().to_vec(),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ pub struct CurrentStatePacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataPacketType for CurrentStatePacket {
|
impl ImprovDataPacketType for CurrentStatePacket {
|
||||||
const packet_type: PacketType = PacketType::CurrentState;
|
const PACKET_TYPE: PacketType = PacketType::CurrentState;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataToPacket for CurrentStatePacket {
|
impl ImprovDataToPacket for CurrentStatePacket {
|
||||||
@ -296,7 +296,7 @@ impl ImprovDataFromPacket for CurrentStatePacket {
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_from_raw_packet(raw_packet: &RawPacket) -> Result<Self, Self::Error>{
|
fn try_from_raw_packet(raw_packet: &RawPacket) -> Result<Self, Self::Error>{
|
||||||
if raw_packet.r#type != Self::packet_type {
|
if raw_packet.r#type != Self::PACKET_TYPE {
|
||||||
return Err(anyhow!("Packet is not CurrentStatePacket"));
|
return Err(anyhow!("Packet is not CurrentStatePacket"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,14 +311,14 @@ pub struct ErrorStatePacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataPacketType for ErrorStatePacket {
|
impl ImprovDataPacketType for ErrorStatePacket {
|
||||||
const packet_type: PacketType = PacketType::ErrorState;
|
const PACKET_TYPE: PacketType = PacketType::ErrorState;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataFromPacket for ErrorStatePacket {
|
impl ImprovDataFromPacket for ErrorStatePacket {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_from_raw_packet(raw_packet: &RawPacket) -> Result<Self, Self::Error>{
|
fn try_from_raw_packet(raw_packet: &RawPacket) -> Result<Self, Self::Error>{
|
||||||
if raw_packet.r#type != Self::packet_type {
|
if raw_packet.r#type != Self::PACKET_TYPE {
|
||||||
return Err(anyhow!("Packet is not ErrorState"));
|
return Err(anyhow!("Packet is not ErrorState"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,7 +334,7 @@ pub struct SendWiFiSettingsPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataPacketType for SendWiFiSettingsPacket {
|
impl ImprovDataPacketType for SendWiFiSettingsPacket {
|
||||||
const packet_type: PacketType = PacketType::RPCCommand;
|
const PACKET_TYPE: PacketType = PacketType::RPCCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataToPacket for SendWiFiSettingsPacket {
|
impl ImprovDataToPacket for SendWiFiSettingsPacket {
|
||||||
@ -360,7 +360,7 @@ pub struct RequestCurrentStatePacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataPacketType for RequestCurrentStatePacket {
|
impl ImprovDataPacketType for RequestCurrentStatePacket {
|
||||||
const packet_type: PacketType = PacketType::RPCCommand;
|
const PACKET_TYPE: PacketType = PacketType::RPCCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataToPacket for RequestCurrentStatePacket {
|
impl ImprovDataToPacket for RequestCurrentStatePacket {
|
||||||
@ -376,7 +376,7 @@ pub struct RequestDeviceInformationPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataPacketType for RequestDeviceInformationPacket {
|
impl ImprovDataPacketType for RequestDeviceInformationPacket {
|
||||||
const packet_type: PacketType = PacketType::RPCCommand;
|
const PACKET_TYPE: PacketType = PacketType::RPCCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataToPacket for RequestDeviceInformationPacket {
|
impl ImprovDataToPacket for RequestDeviceInformationPacket {
|
||||||
@ -392,7 +392,7 @@ pub struct RequestScannedWiFiNetworksPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataPacketType for RequestScannedWiFiNetworksPacket {
|
impl ImprovDataPacketType for RequestScannedWiFiNetworksPacket {
|
||||||
const packet_type: PacketType = PacketType::RPCCommand;
|
const PACKET_TYPE: PacketType = PacketType::RPCCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataToPacket for RequestScannedWiFiNetworksPacket {
|
impl ImprovDataToPacket for RequestScannedWiFiNetworksPacket {
|
||||||
@ -410,14 +410,14 @@ pub struct RPCResultPacket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataPacketType for RPCResultPacket {
|
impl ImprovDataPacketType for RPCResultPacket {
|
||||||
const packet_type: PacketType = PacketType::RPCResult;
|
const PACKET_TYPE: PacketType = PacketType::RPCResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ImprovDataFromPacket for RPCResultPacket {
|
impl ImprovDataFromPacket for RPCResultPacket {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn try_from_raw_packet(raw_packet: &RawPacket) -> Result<Self, Self::Error>{
|
fn try_from_raw_packet(raw_packet: &RawPacket) -> Result<Self, Self::Error>{
|
||||||
if raw_packet.r#type != Self::packet_type {
|
if raw_packet.r#type != Self::PACKET_TYPE {
|
||||||
return Err(anyhow!("Packet is not RPCResult"));
|
return Err(anyhow!("Packet is not RPCResult"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user