Turns a [`ParsedMail`] into [`pgp::composed::Message`]. [`pgp::composed::Message`] is huge (over 4kb), so, it is put on the heap using [`Box`].
(
mail: &'a ParsedMail<'a>,
)
| 238 | /// [`pgp::composed::Message`] is huge (over 4kb), |
| 239 | /// so, it is put on the heap using [`Box`]. |
| 240 | pub fn get_encrypted_pgp_message_boxed<'a>( |
| 241 | mail: &'a ParsedMail<'a>, |
| 242 | ) -> Result<Option<Box<Message<'static>>>> { |
| 243 | let Some(encrypted_data_part) = get_encrypted_mime(mail) else { |
| 244 | return Ok(None); |
| 245 | }; |
| 246 | let data = encrypted_data_part.get_body_raw()?; |
| 247 | let cursor = Cursor::new(data); |
| 248 | let (msg, _headers) = Message::from_armor(cursor)?; |
| 249 | Ok(Some(Box::new(msg))) |
| 250 | } |
| 251 | |
| 252 | /// Returns a reference to the encrypted payload of a message. |
| 253 | pub fn get_encrypted_mime<'a, 'b>(mail: &'a ParsedMail<'b>) -> Option<&'a ParsedMail<'b>> { |
no test coverage detected