From 4abc2ec487017d50bbd3848068dfbfd2d481b045 Mon Sep 17 00:00:00 2001 From: Gabriel Goller Date: Mon, 11 Dec 2023 09:59:02 +0100 Subject: [PATCH] status: use Option on avail/used datastore attrs Instead of returning -1 if we can't get the attributes, we use an Option which will not be serialized on `None`. Signed-off-by: Gabriel Goller --- pbs-api-types/src/datastore.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/pbs-api-types/src/datastore.rs b/pbs-api-types/src/datastore.rs index d4ead1d1..74f610d1 100644 --- a/pbs-api-types/src/datastore.rs +++ b/pbs-api-types/src/datastore.rs @@ -1302,12 +1302,15 @@ pub struct DataStoreStatus { /// Status of a Datastore pub struct DataStoreStatusListItem { pub store: String, - /// The Size of the underlying storage in bytes. (-1 on error) - pub total: i64, - /// The used bytes of the underlying storage. (-1 on error) - pub used: i64, + /// The Size of the underlying storage in bytes. + #[serde(skip_serializing_if = "Option::is_none")] + pub total: Option, + /// The used bytes of the underlying storage. + #[serde(skip_serializing_if = "Option::is_none")] + pub used: Option, /// The available bytes of the underlying storage. (-1 on error) - pub avail: i64, + #[serde(skip_serializing_if = "Option::is_none")] + pub avail: Option, /// A list of usages of the past (last Month). #[serde(skip_serializing_if = "Option::is_none")] pub history: Option>>, @@ -1335,9 +1338,9 @@ impl DataStoreStatusListItem { pub fn empty(store: &str, err: Option) -> Self { DataStoreStatusListItem { store: store.to_owned(), - total: -1, - used: -1, - avail: -1, + total: None, + used: None, + avail: None, history: None, history_start: None, history_delta: None,