g_rust/misc/
hclient.rs

1use std::sync::Mutex;
2use once_cell::sync::Lazy;
3use crate::protocol::vars::packetvariable::PacketVariable;
4
5pub(crate) static CUR_CLIENT: Lazy<Mutex<HClient>> = Lazy::new(| | Mutex::new(HClient::Undefined));
6
7#[derive(PartialEq, Eq, Debug, Clone)]
8pub enum HClient {
9    Unity,
10    Flash,
11    Nitro,
12    Undefined
13}
14
15impl PacketVariable for HClient {
16    fn from_packet(bytes: Vec<u8>) -> (Self, usize) where Self: Sized {
17        let (key, size) = String::from_packet(bytes);
18        (match key.as_str() {
19            "UNITY" => HClient::Unity,
20            "FLASH" => HClient::Flash,
21            "NITRO" => HClient::Nitro,
22            _ => HClient::Undefined
23        }, size)
24    }
25
26    fn to_packet(&self) -> Vec<u8> {
27        (match self {
28            HClient::Unity => "UNITY",
29            HClient::Flash => "FLASH",
30            HClient::Nitro => "NITRO",
31            HClient::Undefined => ""
32        }).to_string().to_packet()
33    }
34}