Skip to main content

rusmes_imap/
command.rs

1//! IMAP command types
2
3/// IMAP commands
4#[derive(Debug, Clone)]
5pub enum ImapCommand {
6    /// LOGIN user password
7    Login { user: String, password: String },
8    /// SELECT mailbox
9    Select { mailbox: String },
10    /// EXAMINE mailbox
11    Examine { mailbox: String },
12    /// FETCH sequence data
13    Fetch {
14        sequence: String,
15        items: Vec<String>,
16    },
17    /// STORE sequence flags (with mode: FLAGS, +FLAGS, -FLAGS)
18    Store {
19        sequence: String,
20        mode: StoreMode,
21        flags: Vec<String>,
22    },
23    /// SEARCH criteria
24    Search { criteria: Vec<String> },
25    /// LIST reference mailbox
26    List { reference: String, mailbox: String },
27    /// LSUB reference mailbox
28    Lsub { reference: String, mailbox: String },
29    /// SUBSCRIBE mailbox
30    Subscribe { mailbox: String },
31    /// UNSUBSCRIBE mailbox
32    Unsubscribe { mailbox: String },
33    /// CREATE mailbox
34    Create { mailbox: String },
35    /// CREATE-SPECIAL-USE mailbox special-use-attr (RFC 6154)
36    CreateSpecialUse {
37        mailbox: String,
38        special_use: String,
39    },
40    /// DELETE mailbox
41    Delete { mailbox: String },
42    /// RENAME old new
43    Rename { old: String, new: String },
44    /// APPEND mailbox \[flags\] \[date-time\] literal
45    Append {
46        mailbox: String,
47        flags: Vec<String>,
48        date_time: Option<String>,
49        message_literal: Vec<u8>,
50    },
51    /// COPY sequence mailbox
52    Copy { sequence: String, mailbox: String },
53    /// MOVE sequence mailbox (RFC 6851)
54    Move { sequence: String, mailbox: String },
55    /// EXPUNGE (permanently delete messages with \Deleted flag)
56    Expunge,
57    /// CLOSE (implicit expunge + deselect)
58    Close,
59    /// CAPABILITY
60    Capability,
61    /// LOGOUT
62    Logout,
63    /// NOOP
64    Noop,
65    /// IDLE (RFC 2177) - push notifications
66    Idle,
67    /// NAMESPACE (RFC 2342) - mailbox namespace discovery
68    Namespace,
69    /// AUTHENTICATE mechanism [initial-response] (RFC 3501 Section 6.2.2)
70    Authenticate {
71        mechanism: String,
72        initial_response: Option<String>,
73    },
74    /// UID command variants (RFC 9051 Section 6.4.8)
75    Uid { subcommand: Box<UidSubcommand> },
76}
77
78/// UID command subcommands
79#[derive(Debug, Clone)]
80pub enum UidSubcommand {
81    /// UID FETCH sequence data
82    Fetch {
83        sequence: String,
84        items: Vec<String>,
85    },
86    /// UID STORE sequence flags
87    Store {
88        sequence: String,
89        mode: StoreMode,
90        flags: Vec<String>,
91    },
92    /// UID SEARCH criteria
93    Search { criteria: Vec<String> },
94    /// UID COPY sequence mailbox
95    Copy { sequence: String, mailbox: String },
96    /// UID MOVE sequence mailbox
97    Move { sequence: String, mailbox: String },
98    /// UID EXPUNGE sequence (RFC 4315)
99    Expunge { sequence: String },
100}
101
102/// STORE command mode
103#[derive(Debug, Clone, PartialEq)]
104pub enum StoreMode {
105    /// Replace flags
106    Replace,
107    /// Add flags
108    Add,
109    /// Remove flags
110    Remove,
111}