From 2f5b4b1c2f225b031bccc23f3d7be65447686c5c Mon Sep 17 00:00:00 2001 From: Joscha Date: Wed, 22 Jun 2022 21:16:54 +0200 Subject: [PATCH] Omit throttled if not true --- cove-tui/src/euph/api/packet.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cove-tui/src/euph/api/packet.rs b/cove-tui/src/euph/api/packet.rs index c269806..c9156ba 100644 --- a/cove-tui/src/euph/api/packet.rs +++ b/cove-tui/src/euph/api/packet.rs @@ -9,8 +9,7 @@ pub struct Packet { pub r#type: PacketType, pub data: Option, pub error: Option, - #[serde(default)] - pub throttled: bool, + pub throttled: Option, pub throttled_reason: Option, } @@ -174,7 +173,7 @@ impl ParsedPacket { Ok(Data::from_value(r#type, data)?) }; - let throttled = if packet.throttled { + let throttled = if packet.throttled == Some(true) { let reason = packet .throttled_reason .unwrap_or_else(|| "no reason given".to_string()); @@ -194,7 +193,7 @@ impl ParsedPacket { pub fn to_packet(self) -> serde_json::Result { let id = self.id; let r#type = self.r#type; - let throttled = self.throttled.is_some(); + let throttled = self.throttled.as_ref().map(|_| true); let throttled_reason = self.throttled; Ok(match self.content {