Skip to main content

mlbt_api/
teams.rs

1use serde::Deserialize;
2use std::fmt;
3
4#[derive(Debug, Clone, Copy)]
5pub enum SportId {
6    /// Major League Baseball
7    Mlb = 1,
8    /// International Baseball (World Baseball Classic, etc.)
9    International = 51,
10}
11
12impl fmt::Display for SportId {
13    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14        write!(f, "{}", *self as u16)
15    }
16}
17
18#[derive(Default, Debug, Deserialize)]
19pub struct TeamsResponse {
20    pub teams: Vec<ApiTeam>,
21}
22
23#[derive(Debug, Deserialize)]
24#[serde(rename_all = "camelCase")]
25pub struct ApiTeam {
26    pub id: u16,
27    pub name: String,
28    pub abbreviation: String,
29    pub team_name: String,
30    pub division: Option<IdLink>,
31    pub sport: Option<IdLink>,
32}
33
34#[derive(Debug, Deserialize)]
35pub struct IdLink {
36    pub id: u16,
37}