From 17a4b1b226a71ef0165e1f6a6428dbd465d0fabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Mon, 29 Jul 2024 20:13:26 -0700 Subject: [PATCH] Make all 'Unknown' variants hidden We only have 'Unknown' variants in enums that are marked non-exhaustive. As such, there really is no point in singling out and treating special such variants: it does not matter if something is formally unknown by the apca crate itself or just unknown by the client application, both cases basically have to be treated similarly. At the same time, many of said enums can be used in input positions, where the Unknown variant simply has no place. As such, this change marks this variant as hidden. Its main purpose, thus, is to prevent potentially fatal (in a long running service) deserialization failures in otherwise legitimate responses. --- src/api/v2/account.rs | 3 ++- src/api/v2/account_activities.rs | 3 ++- src/api/v2/asset.rs | 5 ++++- src/api/v2/order.rs | 1 + src/api/v2/updates.rs | 1 + 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/api/v2/account.rs b/src/api/v2/account.rs index c1493e02..a664e613 100644 --- a/src/api/v2/account.rs +++ b/src/api/v2/account.rs @@ -58,7 +58,8 @@ pub enum Status { /// Any other account status that we have not accounted for. /// /// Note that having any such status should be considered a bug. - #[serde(other)] + #[doc(hidden)] + #[serde(other, rename(serialize = "unknown"))] Unknown, } diff --git a/src/api/v2/account_activities.rs b/src/api/v2/account_activities.rs index e697b881..aa04c627 100644 --- a/src/api/v2/account_activities.rs +++ b/src/api/v2/account_activities.rs @@ -143,7 +143,8 @@ pub enum ActivityType { /// Any other activity type that we have not accounted for. /// /// Note that having any such type should be considered a bug. - #[serde(other)] + #[doc(hidden)] + #[serde(other, rename(serialize = "unknown"))] Unknown, } diff --git a/src/api/v2/asset.rs b/src/api/v2/asset.rs index 2d6afbd5..81d74456 100644 --- a/src/api/v2/asset.rs +++ b/src/api/v2/asset.rs @@ -46,6 +46,7 @@ pub enum Class { /// /// Note that having any such unknown asset class should be considered /// a bug. + #[doc(hidden)] #[serde(other, rename(serialize = "unknown"))] Unknown, } @@ -101,6 +102,7 @@ pub enum Status { /// /// Note that having any such unknown asset class should be considered /// a bug. + #[doc(hidden)] #[serde(other, rename(serialize = "unknown"))] Unknown, } @@ -278,7 +280,8 @@ pub enum Exchange { /// /// Note that having any such unknown exchange should be considered a /// bug. - #[serde(other)] + #[doc(hidden)] + #[serde(other, rename(serialize = "unknown"))] Unknown, } diff --git a/src/api/v2/order.rs b/src/api/v2/order.rs index 78dd418f..8f717203 100644 --- a/src/api/v2/order.rs +++ b/src/api/v2/order.rs @@ -120,6 +120,7 @@ pub enum Status { /// Any other status that we have not accounted for. /// /// Note that having any such status should be considered a bug. + #[doc(hidden)] #[serde(other, rename(serialize = "unknown"))] Unknown, } diff --git a/src/api/v2/updates.rs b/src/api/v2/updates.rs index 31374b63..2cfab3ae 100644 --- a/src/api/v2/updates.rs +++ b/src/api/v2/updates.rs @@ -104,6 +104,7 @@ pub enum OrderStatus { /// Any other status that we have not accounted for. /// /// Note that having any such status should be considered a bug. + #[doc(hidden)] #[serde(other, rename(serialize = "unknown"))] Unknown, }