drive_v3/objects/
reply.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4use super::User;
5
6/// A reply to a comment on a file.
7#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct Reply {
10    /// The ID of the reply.
11    #[serde(skip_serializing_if = "Option::is_none")]
12    pub id: Option<String>,
13
14    /// Identifies what kind of resource this is.
15    ///
16    /// This is always `drive#reply`.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub kind: Option<String>,
19
20    /// The time at which the comment was created (RFC 3339 date-time).
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub created_time: Option<String>,
23
24    /// The last time the comment or any of its replies was modified
25    /// (RFC 3339 date-time).
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub modified_time: Option<String>,
28
29    /// The action the reply performed to the parent comment.
30    ///
31    /// Valid values are:
32    /// - `resolve`
33    /// - `reopen`
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub action: Option<String>,
36
37    /// The author of the reply.
38    ///
39    /// The author's email address and permission ID will not be populated.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub author: Option<User>,
42
43    /// Whether the reply has been deleted.
44    ///
45    /// A deleted reply has no content.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub deleted: Option<bool>,
48
49    /// The content of the reply with HTML formatting.
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub html_content: Option<String>,
52
53    /// The plain text content of the reply.
54    ///
55    /// This field is used for setting the content, while
56    /// [`html_content`](Reply::html_content) should be displayed. This is
57    /// required on creates if no `action` is specified.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub content: Option<String>,
60}
61
62#[doc(hidden)]
63impl From<&Self> for Reply {
64    fn from( reference: &Self ) -> Self {
65        reference.clone()
66    }
67}
68
69impl fmt::Display for Reply {
70    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
71        let json = serde_json::to_string_pretty(&self)
72            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
73
74        write!(f, "{}", json)
75    }
76}
77
78impl Reply {
79    /// Creates a new, empty instance of this struct.
80    pub fn new() -> Self {
81        Self { ..Default::default() }
82    }
83}
84
85/// A list of replies to a comment.
86#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
87#[serde(rename_all = "camelCase")]
88pub struct ReplyList {
89    /// The page token for the next page of replies.
90    ///
91    /// This will be absent if the end of the list has been reached. If the
92    /// token is rejected for any reason, it should be discarded, and
93    /// pagination should be restarted from the first page of results. The page
94    /// token is typically valid for several hours. However, if new items are
95    /// added or removed, your expected results might differ.
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub next_page_token: Option<String>,
98
99    /// Identifies what kind of resource this is.
100    ///
101    /// This is always `drive#replyList`.
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub kind: Option<String>,
104
105    /// The list of replies.
106    ///
107    /// If [`next_page_token`](ReplyList::next_page_token) is populated,
108    /// then this list may be incomplete and an additional page of results
109    /// should be fetched.
110    #[serde(skip_serializing_if = "Option::is_none")]
111    pub replies: Option<Vec<Reply>>,
112}
113
114impl fmt::Display for ReplyList {
115    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
116        let json = serde_json::to_string_pretty(&self)
117            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
118
119        write!(f, "{}", json)
120    }
121}
122
123impl ReplyList {
124    /// Creates a new, empty instance of this struct.
125    pub fn new() -> Self {
126        Self { ..Default::default() }
127    }
128}