mirror of
https://codeberg.org/icewind/ugc-scaper.git
synced 2026-06-03 10:14:11 +02:00
extract region
This commit is contained in:
parent
98b690356c
commit
8fd98b708f
5 changed files with 51 additions and 1 deletions
|
|
@ -115,6 +115,7 @@ pub struct Team {
|
|||
pub tag: String,
|
||||
pub image: String,
|
||||
pub format: GameMode,
|
||||
pub region: Region,
|
||||
pub timezone: Option<String>,
|
||||
pub steam_group: Option<String>,
|
||||
pub division: String,
|
||||
|
|
@ -350,6 +351,42 @@ impl Display for GameMode {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Error)]
|
||||
#[error("Invalid team region: {text}")]
|
||||
pub struct InvalidRegion {
|
||||
pub text: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
|
||||
pub enum Region {
|
||||
Euro,
|
||||
NorthAmerica,
|
||||
SouthAmerica,
|
||||
Asia,
|
||||
Australia,
|
||||
}
|
||||
|
||||
impl FromStr for Region {
|
||||
type Err = InvalidRegion;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"Euro" => Ok(Region::Euro),
|
||||
"EU" => Ok(Region::Euro),
|
||||
"Asia" => Ok(Region::Asia),
|
||||
"ASIA" => Ok(Region::Asia),
|
||||
"NA" => Ok(Region::NorthAmerica),
|
||||
"South American" => Ok(Region::SouthAmerica),
|
||||
"SA" => Ok(Region::SouthAmerica),
|
||||
"AUS" => Ok(Region::Australia),
|
||||
"AUS/NZ" => Ok(Region::Australia),
|
||||
_ => Err(InvalidRegion {
|
||||
text: s.to_string(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
pub struct Transaction {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue