Skip to content

Commit

Permalink
Add api::v2::asset::Status::Unknown variant
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
d-e-s-o committed Jul 29, 2024
1 parent 1e867ae commit 53942d0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/api/v2/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<str> for Status {
Expand All @@ -105,6 +111,7 @@ impl AsRef<str> for Status {
match *self {
Status::Active => "active",
Status::Inactive => "inactive",
Status::Unknown => "unknown",
}
}
}
Expand Down

0 comments on commit 53942d0

Please sign in to comment.