drive_v3/objects/
user.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4/// Information about a Drive user.
5///
6/// See Google's [documentation](https://developers.google.com/drive/api/reference/rest/v3/User) for a full list and more
7/// detailed information.
8#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct User {
11    /// A plain text displayable name for this user.
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub display_name: Option<String>,
14
15    /// Identifies what kind of resource this is. Value: the fixed string "drive#user".
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub kind: Option<String>,
18
19    /// Whether this user is the requesting user.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub me: Option<bool>,
22
23    /// The user's ID as visible in Permission resources.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub permission_id: Option<String>,
26
27    /// The email address of the user. This may not be present in certain contexts if the user has not made their email address
28    /// visible to the requester.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub email_address: Option<String>,
31
32    /// A link to the user's profile photo, if available.
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub photo_link: Option<String>,
35}
36
37impl fmt::Display for User {
38    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
39        let json = serde_json::to_string_pretty(&self)
40            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
41
42        write!(f, "{}", json)
43    }
44}
45
46impl User {
47    /// Creates a new, empty instance of this struct.
48    pub fn new() -> Self {
49        Self { ..Default::default() }
50    }
51}