aboutsummaryrefslogtreecommitdiff
path: root/src/mail/user.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-29 13:16:58 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-29 13:16:58 +0200
commit1bc109df72a3d785211a128b3f28746232258924 (patch)
tree7f9698fb3b61aa506d0a1d8e0835db23b882e23a /src/mail/user.rs
parent3cf91429c7eb675639fbcbf006e04d790645cf77 (diff)
downloadaerogramme-1bc109df72a3d785211a128b3f28746232258924.tar.gz
aerogramme-1bc109df72a3d785211a128b3f28746232258924.zip
Refactoring
Diffstat (limited to 'src/mail/user.rs')
-rw-r--r--src/mail/user.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mail/user.rs b/src/mail/user.rs
new file mode 100644
index 0000000..7465ab0
--- /dev/null
+++ b/src/mail/user.rs
@@ -0,0 +1,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)
+ }
+}