1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use serde::{Serialize, Deserialize};
use super::MessagePart;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CompactMessage {
pub id: String,
#[serde(default, rename = "labelIds")]
pub label_ids: Vec<String>,
#[serde(rename = "threadId")]
pub thread_id: String,
}
///An email message.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Message {
///The ID of the last history record that modified this message.
#[serde(default, rename = "historyId")]
pub history_id: String,
///The immutable ID of the message.
pub id: String,
///The internal message creation timestamp (epoch ms), which determines ordering in the inbox. For normal SMTP-received email, this represents the time the message was originally accepted by Google, which is more reliable than the `Date` header. However, for API-migrated mail, it can be configured by client to be based on the `Date` header.
#[serde(rename = "internalDate")]
pub internal_date: String,
///List of IDs of labels applied to this message.
#[serde(rename = "labelIds")]
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub label_ids: Vec<String>,
///A single MIME message part.
pub payload: MessagePart,
///The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in `messages.get` and `drafts.get` responses when the `format=RAW` parameter is supplied.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub raw: Option<String>,
///Estimated size in bytes of the message.
#[serde(rename = "sizeEstimate")]
pub size_estimate: i64,
///A short part of the message text.
pub snippet: String,
///The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met: 1. The requested `threadId` must be specified on the `Message` or `Draft.Message` you supply with your request. 2. The `References` and `In-Reply-To` headers must be set in compliance with the [RFC 2822](https://tools.ietf.org/html/rfc2822) standard. 3. The `Subject` headers must match.
#[serde(rename = "threadId")]
pub thread_id: String,
}
impl std::fmt::Display for Message {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
write!(f, "{}", serde_json::to_string(self).unwrap())
}
}