From 1feeccdebe83e4fdac8f463c3aae3998eb6ee9d0 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Tue, 14 Oct 2025 16:02:15 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(gmail=5Fclient):=20add=20date?= =?UTF-8?q?=20to=20message=20summary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add date field to MessageSummary struct - implement methods to set and retrieve the date - implement method to list the date and subject --- src/gmail_client/message_summary.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/gmail_client/message_summary.rs b/src/gmail_client/message_summary.rs index 85b7167..054c5ea 100644 --- a/src/gmail_client/message_summary.rs +++ b/src/gmail_client/message_summary.rs @@ -1,6 +1,7 @@ #[derive(Debug, Clone)] pub struct MessageSummary { id: String, + date: Option, subject: Option, } @@ -8,6 +9,7 @@ impl MessageSummary { pub(crate) fn new(id: &str) -> Self { MessageSummary { id: id.to_string(), + date: None, subject: None, } } @@ -27,4 +29,29 @@ impl MessageSummary { "*** No Subject for Message ***" } } + + pub(crate) fn set_date(&mut self, date: &str) { + self.date = Some(date.to_string()) + } + + pub(crate) fn date(&self) -> &str { + if let Some(d) = &self.date { + d + } else { + "*** No Date for Message ***" + } + } + + pub(crate) fn list_date_and_subject(&self) -> String { + let Some(date) = self.date.as_ref() else { + return "***invalid date or subject***".to_string(); + }; + + let Some(subject) = self.subject.as_ref() else { + return "***invalid date or subject***".to_string(); + }; + let s = date[5..16].to_string(); + let s = format!("{s}: {subject}"); + s + } }