hypixel 0.1.0

Rust wrapper for the Hypixel public API.
Documentation
use serde::Deserialize;

/// Represents response from the Hypixel boosters endpoint.
#[derive(Deserialize)]
pub struct BoostersResponse {
    /// Actual data.
    pub boosters: Vec<Booster>
}

/// Booster information object from the boosters endpoint.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Booster {
    /// UUID of the purchaser.
    pub purchaser_uuid: String,
    /// Amount.
    pub amount: f32,
    /// Original length.
    pub original_length: usize,
    /// Current length.
    pub length: usize,
    /// ID of the game.
    pub game_type: usize,
    /// When it was activated.
    pub date_activated: usize
}

/// Represents response from the Hypixel player count endpoint.
#[derive(Deserialize)]
pub struct PlayerCountResponse {
    /// Player distribution.
    pub games: PlayerDistribution,
    /// Total player count.
    #[serde(rename = "playerCount")]
    pub player_count: usize
}

/// Player distribution in different game modes on Hypixel.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub struct PlayerDistribution {
    pub main_lobby: PlayerDistInfo,
    pub tournament_lobby: PlayerDistInfo,
    pub smp: PlayerDistInfo,
    pub legacy: PlayerDistInfo,
    pub uhc: PlayerDistInfo,
    pub survival_games: PlayerDistInfo,
    pub arcade: PlayerDistInfo,
    pub speed_uhc: PlayerDistInfo,
    pub replay: PlayerDistInfo,
    pub duels: PlayerDistInfo,
    pub battleground: PlayerDistInfo,
    pub housing: PlayerDistInfo,
    pub skywars: PlayerDistInfo,
    pub prototype: PlayerDistInfo,
    pub tntgames: PlayerDistInfo,
    pub walls3: PlayerDistInfo,
    pub build_battle: PlayerDistInfo,
    pub wool_games: PlayerDistInfo,
    pub super_smash: PlayerDistInfo,
    pub skyblock: PlayerDistInfo,
    pub murder_mystery: PlayerDistInfo,
    pub bedwars: PlayerDistInfo,
    pub mcgo: PlayerDistInfo,
    pub pit: PlayerDistInfo,
    pub limbo: PlayerDistInfo,
    pub idle: PlayerDistInfo,
    pub queue: PlayerDistInfo
}

#[derive(Debug, Deserialize)]
pub struct PlayerDistInfo {
    /// Number of players.
    pub players: usize,
    /// Players on different modes.
    pub modes: Option<serde_json::Value>
}

/// Represents response from the Hypixel leaderboards endpoint.
#[derive(Deserialize)]
pub struct LeaderboardsResponse {
    /// Actual data.
    pub leaderboards: Leaderboards
}

/// All game modes and their associated list of leaderboards.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub struct Leaderboards {
    pub quakecraft: Vec<Leaderboard>,
    pub walls: Vec<Leaderboard>,
    pub tntgames: Vec<Leaderboard>,
    pub gingerbread: Vec<Leaderboard>,
    pub vampirez: Vec<Leaderboard>,
    pub battleground: Vec<Leaderboard>,
    pub speed_uhc: Vec<Leaderboard>,
    pub mcgo: Vec<Leaderboard>,
    pub paintball: Vec<Leaderboard>,
    pub murder_mystery: Vec<Leaderboard>,
    pub bedwars: Vec<Leaderboard>,
    pub build_battle: Vec<Leaderboard>,
    pub arcade: Vec<Leaderboard>,
    pub true_combat: Vec<Leaderboard>,
    pub survival_games: Vec<Leaderboard>,
    pub skyclash: Vec<Leaderboard>,
    pub super_smash: Vec<Leaderboard>,
    pub arena: Vec<Leaderboard>,
    pub uhc: Vec<Leaderboard>,
    pub skywars: Vec<Leaderboard>,
    pub wool_games: Vec<Leaderboard>,
    pub walls3: Vec<Leaderboard>,
    pub duels: Vec<Leaderboard>
}

/// Leaderboard object.
#[derive(Debug, Deserialize)]
pub struct Leaderboard {
    /// Prefix of the leaderboard, usually the time frame.
    pub prefix: String,
    /// Title of the leaderboard.
    pub title: String,
    /// List of player UUIDs.
    pub leaders: Vec<String>
}

/// Punishment statistics from the Hypixel stats endpoint.
#[derive(Debug, Deserialize)]
pub struct PunishmentStats {
    /// Punishments done by Watch Dog in the past minute.
    #[serde(rename = "watchdog_lastMinute")]
    pub wd_past_minute: usize,
    /// Punishments done by staff daily.
    #[serde(rename = "staff_rollingDaily")]
    pub staff_daily: usize,
    /// Total number of punishments done by Watch Dog.
    #[serde(rename = "watchdog_total")]
    pub wd_total: usize,
    /// Daily punishments done by Watch Dog.
    #[serde(rename = "watchdog_rollingDaily")]
    pub wd_daily: usize,
    /// Total punishments done by staff.
    pub staff_total: usize
}