From f606ec265b3a05fe3e4a0b730b3c4d49f62f6ca9 Mon Sep 17 00:00:00 2001 From: Greg Dean Date: Sun, 1 Mar 2026 17:26:11 -0500 Subject: [PATCH] Add gmail_thr_id() accessor for X-GM-THRID The underlying imap-proto parser already handles X-GM-THRID (GmailThrId AttributeValue), but the Fetch struct only exposed gmail_msg_id() and gmail_labels(). This adds the matching accessor for thread IDs, following the same pattern. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/types/fetch.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/types/fetch.rs b/src/types/fetch.rs index 433002f..8ed2027 100644 --- a/src/types/fetch.rs +++ b/src/types/fetch.rs @@ -266,4 +266,22 @@ impl Fetch { unreachable!() } } + + /// Extract the `X-GM-THRID` of a `FETCH` response + /// + /// See [Access to Gmail thread IDs: X-GM-THRID](https://developers.google.com/gmail/imap/imap-extensions#access_to_gmail_thread_ids_x-gm-thrid) + /// for details. + pub fn gmail_thr_id(&self) -> Option<&u64> { + if let Response::Fetch(_, attrs) = self.response.parsed() { + attrs + .iter() + .filter_map(|av| match av { + AttributeValue::GmailThrId(id) => Some(id), + _ => None, + }) + .next() + } else { + unreachable!() + } + } }