feat(gmail_client): add date to message summary

- add date field to MessageSummary struct
- implement methods to set and retrieve the date
- implement method to list the date and subject
This commit is contained in:
Jeremiah Russell
2025-10-14 16:02:15 +01:00
committed by Jeremiah Russell
parent 9f4b2fa6ae
commit 1feeccdebe

View File

@@ -1,6 +1,7 @@
#[derive(Debug, Clone)]
pub struct MessageSummary {
id: String,
date: Option<String>,
subject: Option<String>,
}
@@ -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
}
}