From 9305e543cf04ee2e53c989d2f29a6ea0b57092c4 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Wed, 25 Sep 2019 22:00:30 +0300 Subject: melib: add a `body` field to Attachment Attachment needs to know the range of bytes where the body part of the attachment is located. The Attachment.raw field contains the entire attachment, headers and body. The new Attachment.body fields contains a `StrBuilder` which contains the offset and length of the body part inside `raw`. --- melib/src/email/attachment_types.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'melib/src/email/attachment_types.rs') diff --git a/melib/src/email/attachment_types.rs b/melib/src/email/attachment_types.rs index 307474d5..f5287df6 100644 --- a/melib/src/email/attachment_types.rs +++ b/melib/src/email/attachment_types.rs @@ -20,6 +20,7 @@ */ use crate::email::attachments::{Attachment, AttachmentBuilder}; use crate::email::parser::BytesExt; + use std::fmt::{Display, Formatter, Result as FmtResult}; use std::str; @@ -123,7 +124,7 @@ pub enum ContentType { Multipart { boundary: Vec, kind: MultipartType, - subattachments: Vec, + parts: Vec, }, MessageRfc822, PGPSignature, @@ -178,7 +179,7 @@ impl ContentType { } } - pub fn make_boundary(subattachments: &Vec) -> String { + pub fn make_boundary(parts: &Vec) -> String { use crate::email::compose::random::gen_boundary; let mut boundary = "bzz_bzz__bzz__".to_string(); let mut random_boundary = gen_boundary(); @@ -186,7 +187,7 @@ impl ContentType { let mut loop_counter = 4096; 'loo: loop { let mut flag = true; - for sub in subattachments { + for sub in parts { 'sub_loop: loop { if sub.raw().find(random_boundary.as_bytes()).is_some() { random_boundary = gen_boundary(); -- cgit v1.2.3