From 2ddd24fc82c7989387708e27789ef5a5f6d8e44c Mon Sep 17 00:00:00 2001 From: Raptorox <70806316+Raptorox@users.noreply.github.com> Date: Tue, 28 Jul 2026 22:38:59 +0200 Subject: [PATCH] split client module --- src/{client.rs => client/mod.rs} | 28 ++-------------------------- src/client/packet_type.rs | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-) rename src/{client.rs => client/mod.rs} (85%) create mode 100644 src/client/packet_type.rs diff --git a/src/client.rs b/src/client/mod.rs similarity index 85% rename from src/client.rs rename to src/client/mod.rs index 83354e3..207c979 100644 --- a/src/client.rs +++ b/src/client/mod.rs @@ -1,30 +1,6 @@ use std::{fmt::Display, io::{self, Read, Write}, net::{TcpStream, ToSocketAddrs}}; - -#[derive(Clone, Copy, PartialEq)] -enum PacketType { - Login = 3, - Command = 2, - Response = 0 -} - -impl PacketType { - fn to_le_bytes(self) -> [u8; 4] { - (self as i32).to_le_bytes() - } -} - -impl TryFrom for PacketType { - type Error = (); - - fn try_from(value: i32) -> Result { - match value { - x if x == Self::Login as i32 => Ok(Self::Login), - x if x == Self::Command as i32 => Ok(Self::Command), - x if x == Self::Response as i32 => Ok(Self::Response), - _ => Err(()) - } - } -} +mod packet_type; +use packet_type::PacketType; #[derive(Debug)] pub enum RconError { diff --git a/src/client/packet_type.rs b/src/client/packet_type.rs new file mode 100644 index 0000000..bc4e0ed --- /dev/null +++ b/src/client/packet_type.rs @@ -0,0 +1,25 @@ +#[derive(Clone, Copy, PartialEq)] +pub enum PacketType { + Login = 3, + Command = 2, + Response = 0 +} + +impl PacketType { + pub fn to_le_bytes(self) -> [u8; 4] { + (self as i32).to_le_bytes() + } +} + +impl TryFrom for PacketType { + type Error = (); + + fn try_from(value: i32) -> Result { + match value { + x if x == Self::Login as i32 => Ok(Self::Login), + x if x == Self::Command as i32 => Ok(Self::Command), + x if x == Self::Response as i32 => Ok(Self::Response), + _ => Err(()) + } + } +} \ No newline at end of file