MCPcopy Create free account
hub / github.com/chatmail/core / get_encrypted_pgp_message_boxed

Function get_encrypted_pgp_message_boxed

src/decrypt.rs:240–250  ·  view source on GitHub ↗

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>,
)

Source from the content-addressed store, hash-verified

238/// [`pgp::composed::Message`] is huge (over 4kb),
239/// so, it is put on the heap using [`Box`].
240pub 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.
253pub fn get_encrypted_mime<'a, 'b>(mail: &'a ParsedMail<'b>) -> Option<&'a ParsedMail<'b>> {

Callers 1

decryptFunction · 0.85

Calls 1

get_encrypted_mimeFunction · 0.85

Tested by

no test coverage detected