steam-user 0.1.0

Steam User web client for Rust - HTTP-based Steam Community interactions
Documentation
use serde::{Deserialize, Serialize};

/// Represents an application owned by the user.
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct OwnedApp {
    #[serde(rename = "appid")]
    pub app_id: u32,
    #[serde(default)]
    pub name: String,
    #[serde(default)]
    pub playtime_forever: u32,
    pub playtime_2weeks: Option<u32>,
    pub capsule_filename: Option<String>,
    pub sort_as: Option<String>,
}

/// Detailed information about a Steam application.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppDetail {
    #[serde(rename = "type")]
    pub app_type: String,
    pub name: String,
    pub steam_appid: u32,
    pub required_age: serde_json::Value,
    pub is_free: bool,
    pub detailed_description: String,
    pub about_the_game: String,
    pub short_description: String,
    pub supported_languages: String,
    pub header_image: String,
    pub website: Option<String>,
    pub developers: Vec<String>,
    pub publishers: Vec<String>,
    pub price_overview: Option<AppPriceOverview>,
    pub platforms: Platforms,
    pub categories: Option<Vec<Category>>,
    pub release_date: ReleaseDate,
    pub background: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppPriceOverview {
    pub currency: String,
    pub initial: u32,
    pub r#final: u32,
    pub discount_percent: u32,
    pub initial_formatted: String,
    pub final_formatted: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Platforms {
    pub windows: bool,
    pub mac: bool,
    pub linux: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Category {
    pub id: u32,
    pub description: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReleaseDate {
    pub coming_soon: bool,
    pub date: String,
}

/// CS:GO account statistics.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CsgoAccountStats {
    pub last_logout_csgo: Option<String>,
    pub last_launch_steam_client: Option<String>,
    pub start_play_csgo: Option<String>,
    pub first_played_cs_franchise: Option<String>,
    pub last_known_ip: Option<String>,
    pub earned_service_medal: Option<String>,
    pub profile_rank: Option<u32>,
    pub xp_to_next_rank: Option<u32>,
    pub anti_addiction_online_time: Option<String>,
}

/// Detailed information about an owned game from the games page.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OwnedAppDetail {
    #[serde(rename = "appid")]
    pub app_id: u32,
    pub name: String,
    #[serde(default)]
    pub logo: String,
    #[serde(default)]
    pub hours: Option<String>,
    #[serde(default)]
    pub hours_forever: Option<String>,
    #[serde(default)]
    pub last_played: Option<u64>,
    #[serde(default)]
    pub friendly_name: Option<String>,
    #[serde(default)]
    pub availstatlinks: Option<serde_json::Value>,
    #[serde(default)]
    pub has_community_visible_stats: Option<bool>,
}

/// Dynamic store user data from Steam store.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DynamicStoreUserData {
    #[serde(rename = "rgOwnedApps", default)]
    pub owned_apps: Vec<u32>,
    #[serde(rename = "rgOwnedPackages", default)]
    pub owned_packages: Vec<u32>,
    #[serde(rename = "rgWishlist", default)]
    pub wishlist: Vec<u32>,
    #[serde(rename = "rgIgnoredApps", default)]
    pub ignored_apps: std::collections::HashMap<String, u32>,
    #[serde(rename = "rgRecommendedTags", default)]
    pub recommended_tags: Vec<serde_json::Value>,
}

/// Steam app version/update check response.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SteamAppVersionInfo {
    pub response: SteamAppVersionResponse,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SteamAppVersionResponse {
    pub success: bool,
    pub up_to_date: Option<bool>,
    pub version_is_listable: Option<bool>,
    pub required_version: Option<u32>,
    pub message: Option<String>,
}

/// Steam app search result item.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AppListItem {
    pub appid: u32,
    pub name: String,
    #[serde(default)]
    pub img: String,
    #[serde(default)]
    pub price: String,
}

/// Simple Steam app list from GetAppList API.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimpleSteamAppList {
    pub applist: SimpleSteamAppListInner,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimpleSteamAppListInner {
    pub apps: Vec<SimpleSteamApp>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimpleSteamApp {
    pub appid: u32,
    pub name: String,
}

/// CS2/CS:GO matchmaking stats parsed from the GCPD matchmaking page.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MatchmakingStats {
    pub matchmaking_cooldown: Option<Vec<CooldownInfo>>,
    pub matchmaking_summary: Vec<MatchmakingSummary>,
    pub matchmaking_per_map: Vec<MatchmakingPerMap>,
    pub last_played_modes: Option<Vec<LastPlayedMode>>,
}

/// Expiration state for a competitive cooldown entry.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CooldownExpiration {
    /// No expiration — cooldown does not expire.
    Never,
    /// Expires at the given UTC timestamp.
    At(chrono::DateTime<chrono::Utc>),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CooldownInfo {
    pub competitive_cooldown_expiration: Option<CooldownExpiration>,
    pub competitive_cooldown_level: Option<u32>,
    pub acknowledged: bool,
}

/// Per-mode win/loss summary (table 2).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MatchmakingSummary {
    pub matchmaking_mode: Option<String>,
    pub wins: Option<u32>,
    pub ties: Option<u32>,
    pub losses: Option<u32>,
    pub skill_group: Option<String>,
    pub last_match: Option<String>,
    pub region: Option<u32>,
}

/// Per-mode per-map win/loss breakdown (table 3).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MatchmakingPerMap {
    pub matchmaking_mode: Option<String>,
    pub map: Option<String>,
    pub wins: Option<u32>,
    pub ties: Option<u32>,
    pub losses: Option<u32>,
    pub skill_group: Option<String>,
    pub last_match: Option<String>,
    pub region: Option<u32>,
}

/// Last-played timestamps for each mode (table 4).
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LastPlayedMode {
    pub matchmaking_mode: Option<String>,
    pub last_match: Option<String>,
}

/// Eligible event app from Steam Points Shop.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EligibleEventApp {
    pub appid: u32,
    pub event_app: bool,
    #[serde(default)]
    pub name: Option<String>,
}

/// Friend ownership info for gifting.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct FriendOwnershipResponse {
    pub ownership_info: Vec<FriendOwnershipInfo>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct FriendOwnershipInfo {
    pub friend_ownership: Vec<FriendOwnership>,
    pub item_id: Option<OwnershipItemId>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct FriendOwnership {
    pub partial_owns_appids: Vec<u32>,
    pub partial_wishes_for: Vec<u32>,
    pub accountid: u32,
    pub already_owns: bool,
    pub wishes_for: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct OwnershipItemId {
    pub appid: Option<u32>,
    pub packageid: Option<u32>,
    pub bundleid: Option<u32>,
    pub tagid: Option<u32>,
    pub creatorid: Option<u32>,
    pub hubcategoryid: Option<u32>,
}