Skip to main content

io_gmail/v1/rest/
labels.rs

1//! Gmail labels (`users.labels`): list, get, create, patch, update,
2//! delete.
3//!
4//! <https://developers.google.com/gmail/api/reference/rest/v1/users.labels>
5
6use alloc::string::String;
7
8use serde::{Deserialize, Serialize};
9
10use crate::v1::rest::messages::GmailMessageListVisibility;
11
12pub mod create;
13pub mod delete;
14pub mod get;
15pub mod list;
16pub mod patch;
17pub mod update;
18
19/// A Gmail label resource.
20///
21/// Labels are used to categorize messages and threads within the
22/// user's mailbox.
23#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
24#[serde(rename_all = "camelCase")]
25pub struct GmailLabel {
26    /// The immutable id of the label.
27    #[serde(default, skip_serializing_if = "String::is_empty")]
28    pub id: String,
29    /// The display name of the label.
30    #[serde(default, skip_serializing_if = "String::is_empty")]
31    pub name: String,
32    /// The owner type of the label, serialized as `type`.
33    #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")]
34    pub label_type: Option<GmailLabelType>,
35    /// The visibility of messages with this label in the message list.
36    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub message_list_visibility: Option<GmailMessageListVisibility>,
38    /// The visibility of the label in the label list.
39    #[serde(default, skip_serializing_if = "Option::is_none")]
40    pub label_list_visibility: Option<GmailLabelListVisibility>,
41    /// The total number of messages with the label.
42    #[serde(default, skip_serializing_if = "Option::is_none")]
43    pub messages_total: Option<u64>,
44    /// The number of unread messages with the label.
45    #[serde(default, skip_serializing_if = "Option::is_none")]
46    pub messages_unread: Option<u64>,
47    /// The total number of threads with the label.
48    #[serde(default, skip_serializing_if = "Option::is_none")]
49    pub threads_total: Option<u64>,
50    /// The number of unread threads with the label.
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    pub threads_unread: Option<u64>,
53    /// The color of the label; only available for user labels.
54    #[serde(default, skip_serializing_if = "Option::is_none")]
55    pub color: Option<GmailLabelColor>,
56}
57
58/// Text and background colors of a user label, given as hex strings.
59#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
60#[serde(rename_all = "camelCase")]
61pub struct GmailLabelColor {
62    /// The text color of the label as a hex string.
63    #[serde(default, skip_serializing_if = "Option::is_none")]
64    pub text_color: Option<String>,
65    /// The background color of the label as a hex string.
66    #[serde(default, skip_serializing_if = "Option::is_none")]
67    pub background_color: Option<String>,
68}
69
70/// Visibility of the label in the label list of the Gmail web client.
71#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
72#[serde(rename_all = "camelCase")]
73pub enum GmailLabelListVisibility {
74    /// The label always shows in the label list.
75    LabelShow,
76    /// The label shows in the label list only when unread.
77    LabelShowIfUnread,
78    /// The label never shows in the label list.
79    LabelHide,
80}
81
82/// Owner of the label: created by Gmail or by the user.
83#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
84#[serde(rename_all = "camelCase")]
85pub enum GmailLabelType {
86    /// A label created by Gmail, like INBOX or TRASH.
87    System,
88    /// A label created by the user.
89    User,
90}