drive_v3/objects/
about.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4use super::{StorageQuota, DriveTheme, User};
5
6/// Information about the user, the user's Drive, and system capabilities.
7///
8/// See Google's
9/// [documentation](https://developers.google.com/drive/api/reference/rest/v3/about)
10/// for a full list and more detailed information.
11///
12/// # Warning
13///
14/// Fields like `teamDriveThemes` or `canCreateTeamDrives` are not included in
15/// this struct, since they are marked as deprecated in Google's
16/// [documentation](https://developers.google.com/drive/api/reference/rest/v3/about).
17///
18/// # Note
19///
20/// All of the fields of [`About`] are an [`Option`] since the values that
21/// Google's API will return are dependent on the
22/// [`fields`](crate::resources::about::GetRequest::fields) requested.
23#[derive(Default, Debug, Clone, Serialize, Deserialize)]
24#[serde(rename_all = "camelCase")]
25pub struct About {
26    /// Identifies what kind of resource this is. Value: the fixed string "drive#about".
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub kind: Option<String>,
29
30    /// The user's storage quota limits and usage. All fields are measured in bytes.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub storage_quota: Option<StorageQuota>,
33
34    /// A list of themes that are supported for shared drives.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub drive_themes: Option<Vec<DriveTheme>>,
37
38    /// Whether the user can create shared drives.
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub can_create_drives: Option<bool>,
41
42    /// A map of source MIME type to possible targets for all supported imports.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub import_formats: Option< serde_json::Map<String, serde_json::Value> >,
45
46    /// A map of source MIME type to possible targets for all supported exports.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    pub export_formats: Option< serde_json::Map<String, serde_json::Value> >,
49
50    /// Whether the user has installed the requesting app.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub app_installed: Option<bool>,
53
54    /// The authenticated user.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub user: Option<User>,
57
58    /// The currently supported folder colors as RGB hex strings.
59    #[serde(skip_serializing_if = "Option::is_none")]
60    pub folder_color_palette: Option<Vec<String>>,
61
62    /// A map of maximum import sizes by MIME type, in bytes.
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub max_import_sizes: Option< serde_json::Map<String, serde_json::Value> >,
65
66    /// The maximum upload size in bytes.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub max_upload_size: Option<String>,
69}
70
71impl fmt::Display for About {
72    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
73        let json = serde_json::to_string_pretty(&self)
74            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
75
76        write!(f, "{}", json)
77    }
78}
79
80impl About {
81    /// Creates a new, empty instance of this struct.
82    pub fn new() -> Self {
83        Self { ..Default::default() }
84    }
85}