Skip to content

Commit

Permalink
Make all 'Unknown' variants hidden
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
d-e-s-o committed Jul 30, 2024
1 parent 53942d0 commit e45a3c6
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/api/v2/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
3 changes: 2 additions & 1 deletion src/api/v2/account_activities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
5 changes: 4 additions & 1 deletion src/api/v2/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
}

Expand Down
1 change: 1 addition & 0 deletions src/api/v2/order.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
1 change: 1 addition & 0 deletions src/api/v2/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit e45a3c6

Please sign in to comment.