From ee07aa8686b7af465730b53fa13e369d85e571b0 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Tue, 18 Jun 2019 21:38:24 +0300 Subject: [PATCH] melib: add other_headers field in Envelope Store headers with non-hardcoded names in a hash map. --- melib/src/email.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/melib/src/email.rs b/melib/src/email.rs index 367a8a227..b5eb5800a 100644 --- a/melib/src/email.rs +++ b/melib/src/email.rs @@ -22,7 +22,7 @@ /*! * Email parsing, handling, sending etc. */ - +use fnv::FnvHashMap; mod compose; pub use self::compose::*; @@ -319,6 +319,7 @@ pub struct Envelope { message_id: MessageID, in_reply_to: Option, references: Option, + other_headers: FnvHashMap, timestamp: UnixTimestamp, thread: ThreadHash, @@ -354,6 +355,7 @@ impl Envelope { message_id: MessageID::default(), in_reply_to: None, references: None, + other_headers: FnvHashMap::default(), timestamp: 0, @@ -476,6 +478,11 @@ impl Envelope { } _ => {} } + } else { + self.other_headers.insert( + String::from_utf8_lossy(name).into(), + String::from_utf8_lossy(value).into(), + ); } } /* @@ -749,6 +756,9 @@ impl Envelope { None => Vec::new(), } } + pub fn other_headers(&self) -> &FnvHashMap { + &self.other_headers + } pub fn thread(&self) -> ThreadHash { self.thread }