use std::ops::Deref;
use serde::Deserialize;
use uuid::Uuid;
#[derive(Debug, Clone, Deserialize)]
pub struct StatusReply {
success: bool,
#[serde(flatten)]
data: StatusData,
}
impl StatusReply {
pub fn success(&self) -> bool {
self.success
}
}
impl Deref for StatusReply {
type Target = StatusData;
fn deref(&self) -> &Self::Target {
&self.data
}
}
#[derive(Debug, Clone, Deserialize)]
pub struct StatusData {
uuid: Uuid,
session: SessionData,
}
impl StatusData {
pub fn uuid(&self) -> Uuid {
self.uuid
}
pub fn online(&self) -> bool {
self.session.online
}
pub fn game_type(&self) -> Option<&str> {
self.session.game_type.as_deref()
}
pub fn mode(&self) -> Option<&str> {
self.session.mode.as_deref()
}
pub fn map(&self) -> Option<&str> {
self.session.map.as_deref()
}
}
#[derive(Debug, Clone, Deserialize)]
struct SessionData {
online: bool,
#[serde(rename = "gameType")]
game_type: Option<String>,
mode: Option<String>,
map: Option<String>,
}