Skip to main content

io_gmail/v1/rest/
settings.rs

1//! Gmail settings (`users.settings`): vacation, IMAP, POP, language,
2//! auto-forwarding, filters, forwarding addresses, delegates and
3//! send-as aliases.
4//!
5//! <https://developers.google.com/gmail/api/reference/rest/v1/users.settings>
6
7use alloc::string::String;
8
9use serde::{Deserialize, Serialize};
10
11pub mod delegates;
12pub mod filters;
13pub mod forwarding_addresses;
14pub mod send_as;
15
16pub mod get_auto_forwarding;
17pub mod get_imap;
18pub mod get_language;
19pub mod get_pop;
20pub mod get_vacation;
21pub mod update_auto_forwarding;
22pub mod update_imap;
23pub mod update_language;
24pub mod update_pop;
25pub mod update_vacation;
26
27/// Auto-forwarding settings of a Gmail account.
28#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
29#[serde(rename_all = "camelCase")]
30pub struct GmailAutoForwarding {
31    /// Whether all incoming mail is automatically forwarded to another
32    /// address.
33    #[serde(default)]
34    pub enabled: bool,
35    /// Email address to which all incoming messages are forwarded.
36    #[serde(default, skip_serializing_if = "Option::is_none")]
37    pub email_address: Option<String>,
38    /// Action applied to messages after they have been forwarded.
39    #[serde(default, skip_serializing_if = "Option::is_none")]
40    pub disposition: Option<GmailDisposition>,
41}
42
43/// IMAP access settings of a Gmail account.
44#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
45#[serde(rename_all = "camelCase")]
46pub struct GmailImapSettings {
47    /// Whether IMAP access is enabled for the account.
48    #[serde(default)]
49    pub enabled: bool,
50    /// Whether Gmail immediately expunges messages marked as deleted in
51    /// IMAP.
52    #[serde(default, skip_serializing_if = "Option::is_none")]
53    pub auto_expunge: Option<bool>,
54    /// Action applied to messages expunged from the last visible IMAP
55    /// folder.
56    #[serde(default, skip_serializing_if = "Option::is_none")]
57    pub expunge_behavior: Option<GmailExpungeBehavior>,
58    /// Optional limit on the number of messages an IMAP folder may contain;
59    /// zero means no limit.
60    #[serde(default, skip_serializing_if = "Option::is_none")]
61    pub max_folder_size: Option<u32>,
62}
63
64/// POP access settings of a Gmail account.
65#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
66#[serde(rename_all = "camelCase")]
67pub struct GmailPopSettings {
68    /// Range of messages accessible via POP.
69    #[serde(default, skip_serializing_if = "Option::is_none")]
70    pub access_window: Option<GmailPopAccessWindow>,
71    /// Action applied to messages after they have been fetched via POP.
72    #[serde(default, skip_serializing_if = "Option::is_none")]
73    pub disposition: Option<GmailDisposition>,
74}
75
76/// Language display settings of a Gmail account.
77#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
78#[serde(rename_all = "camelCase")]
79pub struct GmailLanguageSettings {
80    /// Language to display Gmail in, as an RFC 3066 language tag.
81    #[serde(default)]
82    pub display_language: String,
83}
84
85/// Vacation auto-reply settings of a Gmail account.
86#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
87#[serde(rename_all = "camelCase")]
88pub struct GmailVacationSettings {
89    /// Whether Gmail automatically replies to incoming messages.
90    #[serde(default)]
91    pub enable_auto_reply: bool,
92    /// Optional subject line of the auto-reply.
93    #[serde(default, skip_serializing_if = "Option::is_none")]
94    pub response_subject: Option<String>,
95    /// Response body in plain text format.
96    #[serde(default, skip_serializing_if = "Option::is_none")]
97    pub response_body_plain_text: Option<String>,
98    /// Response body in HTML format.
99    #[serde(default, skip_serializing_if = "Option::is_none")]
100    pub response_body_html: Option<String>,
101    /// Whether responses are only sent to the user's contacts.
102    #[serde(default, skip_serializing_if = "Option::is_none")]
103    pub restrict_to_contacts: Option<bool>,
104    /// Whether responses are only sent to users in the same domain.
105    #[serde(default, skip_serializing_if = "Option::is_none")]
106    pub restrict_to_domain: Option<bool>,
107    /// Optional start time for sending auto-replies, in epoch milliseconds.
108    #[serde(default, skip_serializing_if = "Option::is_none")]
109    pub start_time: Option<String>,
110    /// Optional end time for sending auto-replies, in epoch milliseconds.
111    #[serde(default, skip_serializing_if = "Option::is_none")]
112    pub end_time: Option<String>,
113}
114
115/// Action applied to a message after it has been forwarded or fetched.
116#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
117#[serde(rename_all = "camelCase")]
118pub enum GmailDisposition {
119    /// No disposition specified.
120    DispositionUnspecified,
121    /// Leave the message untouched in the inbox.
122    LeaveInInbox,
123    /// Archive the message.
124    Archive,
125    /// Move the message to the trash.
126    Trash,
127    /// Leave the message in the inbox but mark it as read.
128    MarkRead,
129}
130
131/// Behavior applied to messages expunged from an IMAP folder.
132#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
133#[serde(rename_all = "camelCase")]
134pub enum GmailExpungeBehavior {
135    /// No expunge behavior specified.
136    ExpungeBehaviorUnspecified,
137    /// Archive messages marked as deleted.
138    Archive,
139    /// Move messages marked as deleted to the trash.
140    Trash,
141    /// Immediately and permanently delete messages marked as deleted.
142    DeleteForever,
143}
144
145/// Range of messages accessible through POP.
146#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
147#[serde(rename_all = "camelCase")]
148pub enum GmailPopAccessWindow {
149    /// No access window specified.
150    AccessWindowUnspecified,
151    /// No messages are accessible via POP.
152    Disabled,
153    /// Unfetched messages received from now on are accessible via POP.
154    FromNowOn,
155    /// All unfetched messages are accessible via POP.
156    AllMail,
157}
158
159/// Verification state of an email address owned by a Gmail account.
160#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
161#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
162#[serde(rename_all = "camelCase")]
163pub enum GmailVerificationStatus {
164    /// No verification status specified.
165    VerificationStatusUnspecified,
166    /// The address is verified and usable.
167    Accepted,
168    /// The verification request is awaiting a response.
169    Pending,
170    /// The verification request was rejected.
171    Rejected,
172    /// The verification request expired without a response.
173    Expired,
174}