From d8b4f3b3e52edccc332df4600985e9bc2ce510d3 Mon Sep 17 00:00:00 2001 From: Mroik Date: Sun, 5 Jul 2026 13:37:44 +0300 Subject: Move the mail processing to its own function Signed-off-by: Mroik --- src/process_mail.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/process_mail.rs b/src/process_mail.rs index 90fdd2a..f1ad40d 100644 --- a/src/process_mail.rs +++ b/src/process_mail.rs @@ -24,15 +24,24 @@ impl MailProcessor { // TODO: Check againts self.rx.is_closed() instead to stop the program before consuming all // of the queue. Store the emails not yet processed and restore the queue upon startup. while let Some(mail) = self.rx.recv().await { - let mut db_guard = self.db.lock().await; - db_guard.execute(MailQuery::Insert(&mail))?; - drop(db_guard); - - todo!(); + // TODO: should this be replaced with a send to another actor to pipeline the work? Is + // the complexity worth the speedup? + match self.do_processing(mail).await { + Ok(_) => todo!(), + Err(_) => todo!(), + } } Ok(()) } + + async fn do_processing(&mut self, mail: Mail) -> Result<()> { + let mut db_guard = self.db.lock().await; + db_guard.execute(MailQuery::Insert(&mail))?; + drop(db_guard); + + todo!(); + } } mod tests { -- cgit v1.3.1