From 5622a71cd163e4b18a3eabe8a28a5aedb23ee25d Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Sat, 6 Jan 2024 22:53:41 +0100 Subject: Search MIME headers --- src/imap/imf_view.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/imap/imf_view.rs') diff --git a/src/imap/imf_view.rs b/src/imap/imf_view.rs index 8b52b9e..b56e27d 100644 --- a/src/imap/imf_view.rs +++ b/src/imap/imf_view.rs @@ -1,3 +1,6 @@ +use anyhow::{anyhow, Result}; +use chrono::naive::NaiveDate; + use imap_codec::imap_types::core::{IString, NString}; use imap_codec::imap_types::envelope::{Address, Envelope}; @@ -6,6 +9,10 @@ use eml_codec::imf; pub struct ImfView<'a>(pub &'a imf::Imf<'a>); impl<'a> ImfView<'a> { + pub fn naive_date(&self) -> Result { + Ok(self.0.date.ok_or(anyhow!("date is not set"))?.date_naive()) + } + /// Envelope rules are defined in RFC 3501, section 7.4.2 /// https://datatracker.ietf.org/doc/html/rfc3501#section-7.4.2 /// -- cgit v1.2.3