From 5533bff0548ef9bb98f7a4bc8efb4bb4453917cd Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Fri, 3 Oct 2025 17:13:09 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(list):=20add=20query=20support?= =?UTF-8?q?=20to=20list=20messages=20=20=20-=20allow=20users=20to=20filter?= =?UTF-8?q?=20messages=20using=20a=20query=20string=20=20=20-=20implement?= =?UTF-8?q?=20set=5Fquery=20method=20to=20set=20the=20query=20=20=20-=20ad?= =?UTF-8?q?d=20query=20parameter=20to=20the=20Gmail=20API=20call?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/list.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/list.rs b/src/list.rs index 8249ebb..d181348 100644 --- a/src/list.rs +++ b/src/list.rs @@ -19,6 +19,7 @@ pub struct List { hub: Gmail>, max_results: u32, label_ids: Vec, + query: String, } impl List { @@ -55,6 +56,7 @@ impl List { hub: Gmail::new(client, auth), max_results: DEFAULT_MAX_RESULTS.parse::().unwrap(), label_ids: Vec::new(), + query: String::new(), }) } @@ -77,6 +79,11 @@ impl List { } } + /// Set the query string + pub fn set_query(&mut self, query: &str) { + self.query = query.to_string() + } + /// Run the Gmail api as configured pub async fn run(&self, pages: u32) -> Result<(), Error> { let log_estimate = |est: &Option| { @@ -139,6 +146,11 @@ impl List { call = call.add_label_ids(id); } } + // Add query + if !self.query.is_empty() { + log::debug!("Setting query string `{}`", self.query); + call = call.q(&self.query); + } // Add a page token if it exists if let Some(page_token) = next_page_token { log::debug!("Setting token for next page.");