drive_v3/objects/
thumbnail.rs

1use std::fmt;
2
3use serde::{Serialize, Deserialize};
4
5/// A thumbnail for the file.
6///
7/// This will only be used if Google Drive cannot generate a standard thumbnail.
8#[derive(Default, Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Thumbnail {
11    /// The thumbnail data encoded with URL-safe Base64 (RFC 4648 section 5).
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub image: Option<String>,
14
15    /// The MIME type of the thumbnail.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub mime_type: Option<String>,
18}
19
20impl fmt::Display for Thumbnail {
21    fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result {
22        let json = serde_json::to_string_pretty(&self)
23            .unwrap_or( format!("unable to parse JSON, this is the debug view:\n{:#?}", self) );
24
25        write!(f, "{}", json)
26    }
27}
28
29impl Thumbnail {
30    /// Creates a new, empty instance of this struct.
31    pub fn new() -> Self {
32        Self { ..Default::default() }
33    }
34}