models.rs (1746B)
1 use chrono::{DateTime, Utc}; 2 use serde::Deserialize; 3 4 #[derive(Debug, Deserialize, Clone)] 5 #[serde(rename_all = "camelCase")] 6 pub struct Match { 7 pub utc_date: Option<DateTime<Utc>>, 8 pub status: Option<String>, 9 pub matchday: Option<u32>, 10 pub home_team: Team, 11 pub away_team: Team, 12 pub score: Score, 13 pub competition: Option<Competition>, 14 } 15 16 #[derive(Debug, Deserialize, Clone)] 17 pub struct Competition { 18 pub name: Option<String>, 19 } 20 21 #[derive(Debug, Deserialize, Clone)] 22 pub struct Team { 23 pub name: Option<String>, 24 pub tla: Option<String>, 25 } 26 27 #[derive(Debug, Deserialize, Clone)] 28 #[serde(rename_all = "camelCase")] 29 pub struct Score { 30 pub full_time: ScoreDetail, 31 } 32 33 #[derive(Debug, Deserialize, Default, Clone)] 34 pub struct ScoreDetail { 35 pub home: Option<u32>, 36 pub away: Option<u32>, 37 } 38 39 #[derive(Debug, Deserialize, Clone)] 40 pub struct MatchesResponse { 41 pub matches: Vec<Match>, 42 } 43 44 #[derive(Debug, Deserialize, Clone)] 45 pub struct StandingsResponse { 46 pub standings: Vec<Standing>, 47 } 48 49 #[derive(Debug, Deserialize, Clone)] 50 pub struct Standing { 51 #[serde(rename = "type")] 52 #[allow(dead_code)] 53 pub r#type: String, 54 #[allow(dead_code)] 55 pub stage: String, 56 #[allow(dead_code)] 57 pub group: Option<String>, 58 #[serde(default)] 59 pub table: Vec<TableEntry>, 60 } 61 62 #[derive(Debug, Deserialize, Clone)] 63 #[serde(rename_all = "camelCase")] 64 pub struct TableEntry { 65 pub position: u32, 66 pub team: TeamInfo, 67 pub played_games: u32, 68 pub won: u32, 69 pub draw: u32, 70 pub lost: u32, 71 pub points: u32, 72 pub goals_for: u32, 73 pub goals_against: u32, 74 pub goal_difference: i32, 75 } 76 77 #[derive(Debug, Deserialize, Clone)] 78 pub struct TeamInfo { 79 pub name: String, 80 }