drive_v3/objects/
ids.rs

1use std::fmt;
2use serde::{Serialize, Deserialize};
3
4/// The type of items which an ID can be used for.
5///
6/// Default: [`Files`](IDKind::Files).
7///
8/// # Note
9///
10/// [`Shortcuts`](IDKind::Shortcuts) are only supported in the [`Drive`](super::Space::Drive) space.
11#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
12#[serde(rename_all = "camelCase")]
13pub enum IDKind {
14    /// Files
15    #[default]
16    Files,
17
18    /// Shortcuts
19    Shortcuts
20}
21
22impl fmt::Display for IDKind {
23    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
24        let string = match self {
25            Self::Files     => "files",
26            Self::Shortcuts => "shortcuts",
27        };
28
29        write!(f, "{}", string)
30    }
31}
32
33/// A list of themes that are supported for shared drives.
34#[derive(Default, Debug, Clone, Serialize, Deserialize)]
35#[serde(rename_all = "camelCase")]
36pub struct GeneratedIDs {
37    /// The IDs generated for the requesting user in the specified space.
38    pub ids: Vec<String>,
39
40    /// The type of file that can be created with these IDs.
41    pub space: super::Space,
42
43    /// Identifies what kind of resource this is.
44    ///
45    /// Value is always `drive#generatedIds`.
46    pub kind: String,
47}
48
49impl fmt::Display for GeneratedIDs {
50    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
51        let json = serde_json::to_string_pretty(&self)
52            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
53
54        write!(f, "{}", json)
55    }
56}