From fee450f04b4f6e78b12fe585247118e3ac7a86bf Mon Sep 17 00:00:00 2001 From: TotallyNot <44345987+TotallyNot@users.noreply.github.com> Date: Wed, 10 May 2023 12:04:44 +0200 Subject: [PATCH] updated models --- torn-api/Cargo.toml | 2 +- torn-api/src/key.rs | 4 ++++ torn-api/src/user.rs | 19 ++++++++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/torn-api/Cargo.toml b/torn-api/Cargo.toml index e66a5dd..0861e4e 100644 --- a/torn-api/Cargo.toml +++ b/torn-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "torn-api" -version = "0.5.15" +version = "0.5.16" edition = "2021" authors = ["Pyrit [2111649]"] license = "MIT" diff --git a/torn-api/src/key.rs b/torn-api/src/key.rs index 0e970d2..55d22d1 100644 --- a/torn-api/src/key.rs +++ b/torn-api/src/key.rs @@ -122,6 +122,8 @@ pub enum FactionSelection { Upgrades, Weapons, Lookup, + Caches, + CrimeExp, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] @@ -171,6 +173,8 @@ pub enum TornSelection { Timestamp, Lookup, CityShops, + ItemDetails, + TerritoryNames, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] diff --git a/torn-api/src/user.rs b/torn-api/src/user.rs index 912baae..52053ab 100644 --- a/torn-api/src/user.rs +++ b/torn-api/src/user.rs @@ -168,10 +168,14 @@ pub enum EliminationTeam { #[derive(Debug, Clone)] pub enum Competition { Elimination { - score: i16, + score: i32, attacks: i16, team: EliminationTeam, }, + DogTags { + score: i32, + position: Option, + }, } fn deserialize_comp<'de, D>(deserializer: D) -> Result, D::Error> @@ -186,11 +190,14 @@ where Team, Attacks, TeamName, + Position, } #[derive(Deserialize)] enum CompetitionName { Elimination, + #[serde(rename = "Dog Tags")] + DogTags, } struct CompetitionVisitor; @@ -224,6 +231,7 @@ where let mut score = None; let mut attacks = None; let mut name = None; + let mut position = None; while let Some(key) = map.next_key()? { match key { @@ -236,6 +244,9 @@ where Field::Attacks => { attacks = Some(map.next_value()?); } + Field::Position => { + position = Some(map.next_value()?); + } Field::Team => { let team_raw: &str = map.next_value()?; team = if team_raw.is_empty() { @@ -294,6 +305,12 @@ where Ok(None) } } + CompetitionName::DogTags => { + let score = score.ok_or_else(|| de::Error::missing_field("score"))?; + let position = position.ok_or_else(|| de::Error::missing_field("position"))?; + + Ok(Some(Competition::DogTags { score, position })) + } } } }