drive_v3/objects/
storage_quota.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4/// The user's storage quota limits and usage. All fields are measured in bytes.
5#[derive(Default, Debug, Clone, Serialize, Deserialize)]
6#[serde(rename_all = "camelCase")]
7pub struct StorageQuota {
8    /// The usage limit, if applicable. This will not be present if the user has unlimited storage.
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub limit: Option<String>,
11
12    /// The usage by all files in Google Drive.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub usage_in_drive: Option<String>,
15
16    /// The usage by trashed files in Google Drive.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub usage_in_drive_trash: Option<String>,
19
20    /// The total usage across all services.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub usage: Option<String>,
23}
24
25impl fmt::Display for StorageQuota {
26    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
27        let json = serde_json::to_string_pretty(&self)
28            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
29
30        write!(f, "{}", json)
31    }
32}
33
34impl StorageQuota {
35    /// Creates a new, empty instance of this struct.
36    pub fn new() -> Self {
37        Self { ..Default::default() }
38    }
39}