use std::ops::Deref;
use chrono::{serde::ts_seconds, DateTime, Utc};
use serde::Deserialize;
use crate::{
types::{MatchId, Rank, Season, Time},
user::UserProfile,
};
pub mod requests;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BestTimeInfo {
rank: Rank,
season: Season,
#[serde(with = "ts_seconds")]
date: DateTime<Utc>,
id: MatchId,
time: Time,
user: UserProfile,
}
impl BestTimeInfo {
pub fn rank(&self) -> Rank {
self.rank
}
pub fn season(&self) -> Season {
self.season
}
pub fn date(&self) -> DateTime<Utc> {
self.date
}
pub fn match_id(&self) -> MatchId {
self.id
}
pub fn time(&self) -> Time {
self.time
}
pub fn user(&self) -> &UserProfile {
&self.user
}
}
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
pub struct BestTimeLeaderboard(pub Box<[BestTimeInfo]>);
impl Deref for BestTimeLeaderboard {
type Target = [BestTimeInfo];
fn deref(&self) -> &Self::Target {
&self.0
}
}