use crate::model::prelude::*;
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct AchievementInfo {
pub achievement: Achievement,
pub leaderboard: Vec<AchievementLeaderboardUser>,
pub cutoffs: Cutoffs,
}
impl AsRef<AchievementInfo> for AchievementInfo {
fn as_ref(&self) -> &Self {
self
}
}
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct AchievementLeaderboardUser {
#[serde(rename = "u")]
pub user: PartialUser,
#[serde(rename = "v")]
pub value: f64,
#[serde(rename = "a")]
pub additional_value: Option<f64>,
#[serde(rename = "t")]
pub last_updated_at: String,
}
impl AsRef<AchievementLeaderboardUser> for AchievementLeaderboardUser {
fn as_ref(&self) -> &Self {
self
}
}
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct PartialUser {
#[serde(rename = "_id")]
pub id: UserId,
pub username: String,
pub role: Role,
#[serde(rename = "supporter")]
#[serde(default)] pub is_supporter: bool,
pub country: Option<String>,
}
impl PartialUser {
impl_get_user!(id);
impl_for_username!();
impl_for_role!();
impl_for_country!();
}
impl AsRef<PartialUser> for PartialUser {
fn as_ref(&self) -> &Self {
self
}
}
#[derive(Clone, Debug, Deserialize)]
#[non_exhaustive]
pub struct Cutoffs {
pub total: u32,
pub diamond: Option<f64>,
pub platinum: Option<f64>,
pub gold: Option<f64>,
pub silver: Option<f64>,
pub bronze: Option<f64>,
}
impl AsRef<Cutoffs> for Cutoffs {
fn as_ref(&self) -> &Self {
self
}
}