drive_v3/objects/
revision.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4use super::User;
5
6/// The metadata for a revision to a file.
7#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct Revision {
10    /// The ID of the revision.
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub id: Option<String>,
13
14    /// The MIME type of the revision.
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub mime_type: Option<String>,
17
18    /// Identifies what kind of resource this is.
19    ///
20    /// This is always `drive#revision`.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub kind: Option<String>,
23
24    /// Whether this revision is published.
25    ///
26    /// This is only applicable to Docs Editors files.
27    #[serde(skip_serializing_if = "Option::is_none")]
28    pub published: Option<bool>,
29
30    /// Links for exporting Docs Editors files to specific formats.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub export_links: Option< serde_json::Map<String, serde_json::Value> >,
33
34    /// Whether to keep this revision forever, even if it is no longer the head
35    /// revision.
36    ///
37    /// If not set, the revision will be automatically purged 30 days after
38    /// newer content is uploaded. This can be set on a maximum of 200 revisions
39    /// for a file.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub keep_forever: Option<bool>,
42
43    /// The MD5 checksum of the revision's content.
44    ///
45    /// This is only applicable to files with binary content in Drive.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub md5_checksum: Option<String>,
48
49    /// The last time the revision was modified (RFC 3339 date-time).
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub modified_time: Option<String>,
52
53    /// Whether subsequent revisions will be automatically republished.
54    ///
55    /// This is only applicable to Docs Editors files.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    pub publish_auto: Option<bool>,
58
59    /// Whether this revision is published outside the domain.
60    ///
61    /// This is only applicable to Docs Editors files.
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub published_outside_domain: Option<bool>,
64
65    /// A link to the published revision.
66    ///
67    /// This is only populated for Google Sites files.
68    #[serde(skip_serializing_if = "Option::is_none")]
69    pub published_link: Option<String>,
70
71    /// The size of the revision's content in bytes.
72    ///
73    /// This is only applicable to files with binary content in Drive.
74    #[serde(skip_serializing_if = "Option::is_none")]
75    pub size: Option<String>,
76
77    /// The original filename used to create this revision.
78    ///
79    /// This is only applicable to files with binary content in Drive.
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub original_filename: Option<String>,
82
83    /// The last user to modify this revision.
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub last_modifying_user: Option<User>,
86}
87
88#[doc(hidden)]
89impl From<&Self> for Revision {
90    fn from( reference: &Self ) -> Self {
91        reference.clone()
92    }
93}
94
95impl fmt::Display for Revision {
96    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
97        let json = serde_json::to_string_pretty(&self)
98            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
99
100        write!(f, "{}", json)
101    }
102}
103
104impl Revision {
105    /// Creates a new, empty instance of this struct.
106    pub fn new() -> Self {
107        Self { ..Default::default() }
108    }
109}
110
111/// A list of revisions to a file.
112#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
113#[serde(rename_all = "camelCase")]
114pub struct RevisionList {
115    /// The page token for the next page of replies.
116    ///
117    /// This will be absent if the end of the list has been reached. If the
118    /// token is rejected for any reason, it should be discarded, and
119    /// pagination should be restarted from the first page of results. The page
120    /// token is typically valid for several hours. However, if new items are
121    /// added or removed, your expected results might differ.
122    #[serde(skip_serializing_if = "Option::is_none")]
123    pub next_page_token: Option<String>,
124
125    /// Identifies what kind of resource this is.
126    ///
127    /// This is always `drive#revisionList`.
128    #[serde(skip_serializing_if = "Option::is_none")]
129    pub kind: Option<String>,
130
131    /// The list of replies.
132    ///
133    /// If [`next_page_token`](RevisionList::next_page_token) is populated,
134    /// then this list may be incomplete and an additional page of results
135    /// should be fetched.
136    #[serde(skip_serializing_if = "Option::is_none")]
137    pub revisions: Option<Vec<Revision>>,
138}
139
140impl fmt::Display for RevisionList {
141    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
142        let json = serde_json::to_string_pretty(&self)
143            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
144
145        write!(f, "{}", json)
146    }
147}
148
149impl RevisionList {
150    /// Creates a new, empty instance of this struct.
151    pub fn new() -> Self {
152        Self { ..Default::default() }
153    }
154}