async_imap/types/
mailbox.rs

1use super::{Flag, Uid};
2use std::fmt;
3
4/// Meta-information about an IMAP mailbox, as returned by
5/// [`SELECT`](https://tools.ietf.org/html/rfc3501#section-6.3.1) and friends.
6#[derive(Clone, Debug, Eq, PartialEq, Hash, Default)]
7pub struct Mailbox {
8    /// Defined flags in the mailbox.  See the description of the [FLAGS
9    /// response](https://tools.ietf.org/html/rfc3501#section-7.2.6) for more detail.
10    pub flags: Vec<Flag<'static>>,
11
12    /// The number of messages in the mailbox.  See the description of the [EXISTS
13    /// response](https://tools.ietf.org/html/rfc3501#section-7.3.1) for more detail.
14    pub exists: u32,
15
16    /// The number of messages with the \Recent flag set. See the description of the [RECENT
17    /// response](https://tools.ietf.org/html/rfc3501#section-7.3.2) for more detail.
18    pub recent: u32,
19
20    /// The message sequence number of the first unseen message in the mailbox.  If this is
21    /// missing, the client can not make any assumptions about the first unseen message in the
22    /// mailbox, and needs to issue a `SEARCH` command if it wants to find it.
23    pub unseen: Option<u32>,
24
25    /// A list of message flags that the client can change permanently.  If this is missing, the
26    /// client should assume that all flags can be changed permanently. If the client attempts to
27    /// STORE a flag that is not in this list list, the server will either ignore the change or
28    /// store the state change for the remainder of the current session only.
29    pub permanent_flags: Vec<Flag<'static>>,
30
31    /// The next unique identifier value.  If this is missing, the client can not make any
32    /// assumptions about the next unique identifier value.
33    pub uid_next: Option<Uid>,
34
35    /// The unique identifier validity value.  See [`Uid`] for more details.  If this is missing,
36    /// the server does not support unique identifiers.
37    pub uid_validity: Option<u32>,
38
39    /// Highest mailbox mod-sequence as defined in [RFC-7162](https://tools.ietf.org/html/rfc7162).
40    pub highest_modseq: Option<u64>,
41}
42
43impl fmt::Display for Mailbox {
44    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45        write!(
46            f,
47            "flags: {:?}, exists: {}, recent: {}, unseen: {:?}, permanent_flags: {:?},\
48             uid_next: {:?}, uid_validity: {:?}",
49            self.flags,
50            self.exists,
51            self.recent,
52            self.unseen,
53            self.permanent_flags,
54            self.uid_next,
55            self.uid_validity
56        )
57    }
58}