From 53942d016834254f39a1438f30c6a5c9029d4a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Sun, 28 Jul 2024 21:56:48 -0700 Subject: [PATCH] Add api::v2::asset::Status::Unknown variant With the api::v2::asset::Status being declared as non-exhaustive by now, it seems logical to also support the deserialization of potentially unknown variants, otherwise a deserialization failure could have disastrous consequences when listing tradeable assets. As such, this change adds an Unknown variant to the enum, similar to what we have elsewhere. --- src/api/v2/asset.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/api/v2/asset.rs b/src/api/v2/asset.rs index e406275..2d6afbd 100644 --- a/src/api/v2/asset.rs +++ b/src/api/v2/asset.rs @@ -97,6 +97,12 @@ pub enum Status { /// The asset is inactive. #[serde(rename = "inactive")] Inactive, + /// Any other asset status that we have not accounted for. + /// + /// Note that having any such unknown asset class should be considered + /// a bug. + #[serde(other, rename(serialize = "unknown"))] + Unknown, } impl AsRef for Status { @@ -105,6 +111,7 @@ impl AsRef for Status { match *self { Status::Active => "active", Status::Inactive => "inactive", + Status::Unknown => "unknown", } } }