aboutsummaryrefslogtreecommitdiff
path: root/src/imap/capability.rs
blob: b98e8f8d1dd494b200fec060a400e888892ad4d9 (plain) (blame)
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
use imap_codec::imap_types::core::NonEmptyVec;
use imap_codec::imap_types::response::Capability;

#[derive(Debug, Clone)]
pub struct ServerCapability {
    r#move: bool,
    unselect: bool,
}

impl Default for ServerCapability {
    fn default() -> Self {
        Self {
            r#move: true,
            unselect: true,
        }
    }
}

impl ServerCapability {
    pub fn to_vec(&self) -> NonEmptyVec<Capability<'static>> {
        let mut acc = vec![Capability::Imap4Rev1];
        if self.r#move {
            acc.push(Capability::Move);
        }
        if self.unselect {
            acc.push(Capability::try_from("UNSELECT").unwrap());
        }
        acc.try_into().unwrap()
    }
}