From 26f14df3f460320b2e2d31deb9d3cef90f43790c Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Thu, 2 Nov 2023 09:42:50 +0100 Subject: [PATCH] we are doomed with static types --- src/mail/incoming.rs | 5 +++-- src/mail/user.rs | 2 -- src/storage/mod.rs | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/mail/incoming.rs b/src/mail/incoming.rs index b7d2f48..7094b42 100644 --- a/src/mail/incoming.rs +++ b/src/mail/incoming.rs @@ -23,6 +23,7 @@ use crate::mail::unique_ident::*; use crate::mail::user::User; use crate::mail::IMF; use crate::time::now_msec; +use crate::storage::Sto; const INCOMING_PK: &str = "incoming"; const INCOMING_LOCK_SK: &str = "lock"; @@ -139,14 +140,14 @@ async fn incoming_mail_watch_process_internal( Ok(()) } -async fn handle_incoming_mail( +async fn handle_incoming_mail( user: &Arc, s3: &S3Client, inbox: &Arc, lock_held: &watch::Receiver, ) -> Result<()> { let lor = ListObjectsV2Request { - bucket: user.creds.storage.bucket.clone(), + bucket: user.creds.storage.engine::().bucket.clone(), max_keys: Some(1000), prefix: Some("incoming/".into()), ..Default::default() diff --git a/src/mail/user.rs b/src/mail/user.rs index 360786d..5523c2a 100644 --- a/src/mail/user.rs +++ b/src/mail/user.rs @@ -30,8 +30,6 @@ pub const INBOX: &str = "INBOX"; const MAILBOX_LIST_PK: &str = "mailboxes"; const MAILBOX_LIST_SK: &str = "list"; -use crate::storage::*; - pub struct User { pub username: String, pub creds: Credentials, diff --git a/src/storage/mod.rs b/src/storage/mod.rs index c0835e6..ee475ee 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -36,8 +36,8 @@ pub trait Sto: Sized { } pub struct Engine { - bucket: String, - row: T::Builder, + pub bucket: String, + pub row: T::Builder, } pub enum AnyEngine { @@ -45,7 +45,7 @@ pub enum AnyEngine { Garage(Engine), } impl AnyEngine { - fn engine(&self) -> &Engine { + pub fn engine(&self) -> &Engine { match self { Self::InMemory(x) => x, Self::Garage(x) => x,