drive_v3/objects/
change.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4use super::{File, DriveInfo};
5
6/// A list of changes for a user.
7#[derive(Default, Debug, Clone, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct ChangeList {
10    /// Identifies what kind of resource this is.
11    ///
12    /// This is always `drive#changeList`.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub kind: Option<String>,
15
16    /// The page token for the next page of changes.
17    ///
18    /// This will be absent if the end of the changes list has been reached.
19    /// The page token doesn't expire.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub next_page_token: Option<String>,
22
23    /// The starting page token for future changes.
24    ///
25    /// This will be present only if the end of the current changes list has
26    /// been reached. The page token doesn't expire.
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub new_start_page_token: Option<String>,
29
30    /// The list of changes.
31    ///
32    /// If [`next_page_token`](ChangeList::next_page_token) is populated, then
33    /// this list may be incomplete and an additional page of results should be
34    /// fetched.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub changes: Option<Vec<Change>>,
37}
38
39impl fmt::Display for ChangeList {
40    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
41        let json = serde_json::to_string_pretty(&self)
42            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
43
44        write!(f, "{}", json)
45    }
46}
47
48impl ChangeList {
49    /// Creates a new, empty instance of this struct.
50    pub fn new() -> Self {
51        Self { ..Default::default() }
52    }
53}
54
55/// A change to a file or shared drive.
56#[derive(Default, Debug, Clone, Serialize, Deserialize)]
57#[serde(rename_all = "camelCase")]
58pub struct Change {
59    /// Identifies what kind of resource this is.
60    ///
61    /// This is always `drive#change`.
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub kind: Option<String>,
64
65    /// Whether the file or shared drive has been removed from this list of
66    /// changes, for example by deletion or loss of access.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub removed: Option<bool>,
69
70    /// The updated state of the file.
71    ///
72    /// Present if the type is file and the file has not been removed from this
73    /// list of changes.
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub file: Option<File>,
76
77    /// The ID of the file which has changed.
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub file_id: Option<String>,
80
81    /// The time of this change (RFC 3339 date-time).
82    #[serde(skip_serializing_if = "Option::is_none")]
83    pub time: Option<String>,
84
85    /// The ID of the shared drive associated with this change.
86    #[serde(skip_serializing_if = "Option::is_none")]
87    pub drive_id: Option<String>,
88
89    /// The type of the change.
90    ///
91    /// Possible values are `file` and `drive`.
92    #[serde(skip_serializing_if = "Option::is_none")]
93    pub change_type: Option<String>,
94
95    /// The updated state of the shared drive.
96    ///
97    /// Present if the [`change_type`](Change::change_type) is `drive`, the user
98    /// is still a member of the shared drive, and the shared drive has not been
99    /// deleted.
100    #[serde(skip_serializing_if = "Option::is_none")]
101    pub drive: Option<DriveInfo>,
102}
103
104impl fmt::Display for Change {
105    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
106        let json = serde_json::to_string_pretty(&self)
107            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
108
109        write!(f, "{}", json)
110    }
111}
112
113impl Change {
114    /// Creates a new, empty instance of this struct.
115    pub fn new() -> Self {
116        Self { ..Default::default() }
117    }
118}