battlebit_api/endpoints/servers/
mod.rs1use derive_getters::Getters;
2use serde::{Deserialize, Serialize};
3
4use crate::enums::{MapSize, Gamemode, Region, DayNight, AntiCheat};
5
6#[allow(dead_code)]
8#[derive(Deserialize, Serialize, Clone, Debug, Getters, PartialEq)]
9#[serde(rename_all(deserialize = "PascalCase"))]
10#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
11pub struct ServerData {
12 #[cfg_attr(feature = "utoipa", schema(example = "Super Awesome Server"))]
13 name: String,
15 #[cfg_attr(feature = "utoipa", schema(example = "GenericMap"))]
16 map: String,
18 #[cfg_attr(feature = "utoipa", schema(example = MapSize::Ultra))]
19 map_size: MapSize,
21 #[cfg_attr(feature = "utoipa", schema(example = Gamemode::Conquest))]
22 gamemode: Gamemode,
24 #[cfg_attr(feature = "utoipa", schema(example = Region::Europe))]
25 region: Region,
27
28 #[serde(rename(deserialize = "Players"))]
29 #[cfg_attr(feature = "utoipa", schema(example = 124))]
30 player_count: u8,
33
34 #[serde(rename(deserialize = "QueuePlayers"))]
35 #[cfg_attr(feature = "utoipa", schema(example = 2))]
36 queued_player_count: u16,
39
40 #[cfg_attr(feature = "utoipa", schema(example = 254))]
41 max_players: u8,
44
45 #[cfg_attr(feature = "utoipa", schema(example = 120))]
46 hz: u8,
49
50 #[cfg_attr(feature = "utoipa", schema(example = DayNight::Day))]
51 day_night: DayNight,
53 #[cfg_attr(feature = "utoipa", schema(example = false))]
54 is_official: bool,
56 #[cfg_attr(feature = "utoipa", schema(example = false))]
57 has_password: bool,
59 #[cfg_attr(feature = "utoipa", schema(example = AntiCheat::EasyAntiCheat))]
60 anti_cheat: AntiCheat,
62 #[cfg_attr(feature = "utoipa", schema(example = "Production 2.2.5 Hotfix"))]
63 build: String,
65}
66
67impl ServerData {
68 pub fn has_unknown(&self) -> bool {
71 if *self.anti_cheat() == AntiCheat::Unknown { return true }
72 if *self.region() == Region::Unknown { return true }
73 if *self.gamemode() == Gamemode::Unknown { return true }
74 if *self.map_size() == MapSize::Unknown { return true }
75
76 false
77 }
78}