✨ feat(message_list): enhance message list functionality and debugging
- implement Debug trait for MessageList struct for better debugging - add getter methods for message_ids, label_ids, and hub for external access - change log level check to include Info and higher for message subject logging
This commit is contained in:
committed by
Jeremiah Russell
parent
b7792bedc6
commit
f7a8066f66
@@ -1,3 +1,5 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
use google_gmail1::{
|
||||
Gmail,
|
||||
api::ListMessagesResponse,
|
||||
@@ -23,6 +25,17 @@ pub struct MessageList {
|
||||
query: String,
|
||||
}
|
||||
|
||||
impl Debug for MessageList {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("MessageList")
|
||||
.field("max_results", &self.max_results)
|
||||
.field("label_ids", &self.label_ids)
|
||||
.field("message_ids", &self.message_ids)
|
||||
.field("query", &self.query)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl MessageList {
|
||||
/// Create a new List struct and add the Gmail api connection.
|
||||
pub async fn new(credential: &str) -> Result<Self, Error> {
|
||||
@@ -86,6 +99,21 @@ impl MessageList {
|
||||
self.query = query.to_string()
|
||||
}
|
||||
|
||||
/// Get a reference to the message_ids
|
||||
pub fn message_ids(&self) -> Vec<String> {
|
||||
self.message_ids.clone()
|
||||
}
|
||||
|
||||
/// Get a reference to the message_ids
|
||||
pub fn label_ids(&self) -> Vec<String> {
|
||||
self.label_ids.clone()
|
||||
}
|
||||
|
||||
/// Get the hub
|
||||
pub fn hub(&self) -> Gmail<HttpsConnector<HttpConnector>> {
|
||||
self.hub.clone()
|
||||
}
|
||||
|
||||
/// Run the Gmail api as configured
|
||||
pub async fn run(&mut self, pages: u32) -> Result<(), Error> {
|
||||
let list = self.messages_list(None).await?;
|
||||
@@ -117,7 +145,7 @@ impl MessageList {
|
||||
}
|
||||
}
|
||||
|
||||
if log::max_level() <= log::Level::Info {
|
||||
if log::max_level() >= log::Level::Info {
|
||||
self.log_message_subjects().await?;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user