New: derive Serialize on battle results

This commit is contained in:
eigenein committed 2022-12-05 22:26:47 +01:00
1 parent f63ba599ec
commit 1e0ce05c18
1 file changed
+9 -6
+9 -6
View File
@@ -1,5 +1,6 @@
use prost::bytes::Buf; use prost::bytes::Buf;
use prost::Message; use prost::Message;
use serde::Serialize;
use crate::error::Error; use crate::error::Error;
use crate::result::Result; use crate::result::Result;
@@ -14,7 +15,7 @@ impl BattleResults {
} }
/// Parsed battle results. /// Parsed battle results.
#[derive(Message)] #[derive(Message, Serialize)]
pub struct BattleResults { pub struct BattleResults {
/// Battle timestamp. /// Battle timestamp.
#[prost(int64, tag = "2")] #[prost(int64, tag = "2")]
@@ -30,7 +31,7 @@ pub struct BattleResults {
} }
/// Battle player. /// Battle player.
#[derive(Message)] #[derive(Message, Serialize)]
pub struct Player { pub struct Player {
/// Player's account ID. /// Player's account ID.
#[prost(uint32, tag = "1")] #[prost(uint32, tag = "1")]
@@ -42,7 +43,7 @@ pub struct Player {
} }
/// Player's extended information. /// Player's extended information.
#[derive(Message)] #[derive(Message, Serialize)]
pub struct PlayerInfo { pub struct PlayerInfo {
/// Player's nickname. /// Player's nickname.
#[prost(string, tag = "1")] #[prost(string, tag = "1")]
@@ -62,7 +63,9 @@ pub struct PlayerInfo {
pub clan_tag: Option<String>, pub clan_tag: Option<String>,
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, prost::Enumeration)] #[derive(
Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, prost::Enumeration, Serialize,
)]
#[repr(i32)] #[repr(i32)]
pub enum TeamNumber { pub enum TeamNumber {
One = 1, One = 1,
@@ -70,7 +73,7 @@ pub enum TeamNumber {
} }
/// Player's battle results. /// Player's battle results.
#[derive(Message)] #[derive(Message, Serialize)]
pub struct PlayerResults { pub struct PlayerResults {
/// Looks like some sort of sequential result ID. They reference each other, /// Looks like some sort of sequential result ID. They reference each other,
/// but I haven't figured this out yet. /// but I haven't figured this out yet.
@@ -83,7 +86,7 @@ pub struct PlayerResults {
} }
/// Extended player's results information. /// Extended player's results information.
#[derive(Message)] #[derive(Message, Serialize)]
pub struct PlayerResultsInfo { pub struct PlayerResultsInfo {
/// Credits earned – without special awards and medals and premium account excluded. /// Credits earned – without special awards and medals and premium account excluded.
#[prost(uint32, tag = "2")] #[prost(uint32, tag = "2")]