aboutsummaryrefslogtreecommitdiff
path: root/src/mail/user.rs
blob: 7465ab0d51f78272ba2ad9046c944be7b3dad7e5 (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
31
use anyhow::Result;

use k2v_client::K2vClient;
use rusoto_s3::S3Client;

use crate::login::Credentials;
use crate::mail::mailbox::Mailbox;

pub struct User {
    pub username: String,
    pub creds: Credentials,
    pub s3_client: S3Client,
    pub k2v_client: K2vClient,
}

impl User {
    pub fn new(username: String, creds: Credentials) -> Result<Self> {
        let s3_client = creds.s3_client()?;
        let k2v_client = creds.k2v_client()?;
        Ok(Self {
            username,
            creds,
            s3_client,
            k2v_client,
        })
    }

    pub fn open_mailbox(&self, name: String) -> Result<Mailbox> {
        Mailbox::new(&self.creds, name)
    }
}