1use serde::{Deserialize, Serialize};
4use std::fmt;
5
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
8#[serde(rename_all = "lowercase")]
9pub enum Region {
10 Us,
12 Us2,
14 Uk,
16 Au,
18 Eu,
20}
21
22impl fmt::Display for Region {
23 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24 match self {
25 Region::Us => write!(f, "us"),
26 Region::Us2 => write!(f, "us2"),
27 Region::Uk => write!(f, "uk"),
28 Region::Au => write!(f, "au"),
29 Region::Eu => write!(f, "eu"),
30 }
31 }
32}
33
34#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
36#[serde(rename_all = "snake_case")]
37pub enum Market {
38 H2h,
40 Spreads,
42 Totals,
44 Outrights,
46 H2hLay,
48 #[serde(untagged)]
50 Custom(String),
51}
52
53impl fmt::Display for Market {
54 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
55 match self {
56 Market::H2h => write!(f, "h2h"),
57 Market::Spreads => write!(f, "spreads"),
58 Market::Totals => write!(f, "totals"),
59 Market::Outrights => write!(f, "outrights"),
60 Market::H2hLay => write!(f, "h2h_lay"),
61 Market::Custom(s) => write!(f, "{}", s),
62 }
63 }
64}
65
66impl From<&str> for Market {
67 fn from(s: &str) -> Self {
68 match s {
69 "h2h" => Market::H2h,
70 "spreads" => Market::Spreads,
71 "totals" => Market::Totals,
72 "outrights" => Market::Outrights,
73 "h2h_lay" => Market::H2hLay,
74 other => Market::Custom(other.to_string()),
75 }
76 }
77}
78
79#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
81#[serde(rename_all = "lowercase")]
82pub enum DateFormat {
83 #[default]
85 Iso,
86 Unix,
88}
89
90impl fmt::Display for DateFormat {
91 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
92 match self {
93 DateFormat::Iso => write!(f, "iso"),
94 DateFormat::Unix => write!(f, "unix"),
95 }
96 }
97}
98
99#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
101#[serde(rename_all = "lowercase")]
102pub enum OddsFormat {
103 #[default]
105 Decimal,
106 American,
108}
109
110impl fmt::Display for OddsFormat {
111 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
112 match self {
113 OddsFormat::Decimal => write!(f, "decimal"),
114 OddsFormat::American => write!(f, "american"),
115 }
116 }
117}
118
119pub type SportKey = String;
121
122pub type EventId = String;
124
125pub(crate) fn format_csv<T: fmt::Display>(items: &[T]) -> String {
127 items
128 .iter()
129 .map(|i| i.to_string())
130 .collect::<Vec<_>>()
131 .join(",")
132}