1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! all information that can be contained in a GSI update

use std::collections::HashMap;

use serde::{Serialize, Deserialize, de::IgnoredAny};

pub mod player;
use player::Player;

pub mod map;
use map::Map;

pub mod round;
use round::Round;

// TODO abuse generics to align subscriptions with these types

/// a team
#[derive(Clone, Debug, Deserialize, Serialize)]
pub enum Team {
    /// counter-terrorists
    CT,
    /// terrorists
    T,
}

/// an update received from CS:GO
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Update {
    /// map info
    pub map: Option<Map>,
    /// player info
    pub player: Option<Player>,
    /// provider (CS:GO) info
    pub provider: Option<Provider>,
    /// authentication info, matching initial config
    pub auth: HashMap<String, String>,
    /// round info
    pub round: Option<Round>,
    #[serde(skip_serializing, default)]
    added: IgnoredAny,
    #[serde(skip_serializing, default)]
    previously: IgnoredAny,
}

/// information about the GSI info provider (CS:GO itself)
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct Provider {
    /// game name
    pub name: String,
    /// steam app ID
    #[serde(rename = "appid")]
    pub app_id: u64,
    /// version number
    pub version: u64,
    /// player's steam ID
    #[serde(rename = "steamid")]
    pub steam_id: String,
    /// update timestamp
    pub timestamp: u64,
}