mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-05-03 01:45:32 +00:00
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 <g.goller@proxmox.com>
This commit is contained in:
parent
0cac699e0c
commit
cbb478fa19
@ -1302,12 +1302,15 @@ pub struct DataStoreStatus {
|
|||||||
/// Status of a Datastore
|
/// Status of a Datastore
|
||||||
pub struct DataStoreStatusListItem {
|
pub struct DataStoreStatusListItem {
|
||||||
pub store: String,
|
pub store: String,
|
||||||
/// The Size of the underlying storage in bytes. (-1 on error)
|
/// The Size of the underlying storage in bytes.
|
||||||
pub total: i64,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
/// The used bytes of the underlying storage. (-1 on error)
|
pub total: Option<u64>,
|
||||||
pub used: i64,
|
/// The used bytes of the underlying storage.
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub used: Option<u64>,
|
||||||
/// The available bytes of the underlying storage. (-1 on error)
|
/// The available bytes of the underlying storage. (-1 on error)
|
||||||
pub avail: i64,
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub avail: Option<u64>,
|
||||||
/// A list of usages of the past (last Month).
|
/// A list of usages of the past (last Month).
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub history: Option<Vec<Option<f64>>>,
|
pub history: Option<Vec<Option<f64>>>,
|
||||||
@ -1335,9 +1338,9 @@ impl DataStoreStatusListItem {
|
|||||||
pub fn empty(store: &str, err: Option<String>) -> Self {
|
pub fn empty(store: &str, err: Option<String>) -> Self {
|
||||||
DataStoreStatusListItem {
|
DataStoreStatusListItem {
|
||||||
store: store.to_owned(),
|
store: store.to_owned(),
|
||||||
total: -1,
|
total: None,
|
||||||
used: -1,
|
used: None,
|
||||||
avail: -1,
|
avail: None,
|
||||||
history: None,
|
history: None,
|
||||||
history_start: None,
|
history_start: None,
|
||||||
history_delta: None,
|
history_delta: None,
|
||||||
|
@ -68,9 +68,9 @@ pub async fn datastore_status(
|
|||||||
|
|
||||||
let mut entry = DataStoreStatusListItem {
|
let mut entry = DataStoreStatusListItem {
|
||||||
store: store.clone(),
|
store: store.clone(),
|
||||||
total: status.total as i64,
|
total: Some(status.total),
|
||||||
used: status.used as i64,
|
used: Some(status.used),
|
||||||
avail: status.available as i64,
|
avail: Some(status.available),
|
||||||
history: None,
|
history: None,
|
||||||
history_start: None,
|
history_start: None,
|
||||||
history_delta: None,
|
history_delta: None,
|
||||||
|
Loading…
Reference in New Issue
Block a user