summaryrefslogtreecommitdiffstats
path: root/melib/src/email/address.rs
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-09-25 22:00:30 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-09-26 13:10:06 +0300
commit9305e543cf04ee2e53c989d2f29a6ea0b57092c4 (patch)
tree9b59f34505b0825ae6e8d003a190a8f3c30aac72 /melib/src/email/address.rs
parent5a53020f3d2d7819c5c24871d2dd126c5a2ec84c (diff)
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`.
Diffstat (limited to 'melib/src/email/address.rs')
-rw-r--r--melib/src/email/address.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/melib/src/email/address.rs b/melib/src/email/address.rs
index dd771d92..4845d328 100644
--- a/melib/src/email/address.rs
+++ b/melib/src/email/address.rs
@@ -129,7 +129,7 @@ impl fmt::Debug for Address {
}
/// Helper struct to return slices from a struct field on demand.
-#[derive(Clone, Debug, Serialize, Deserialize, Default)]
+#[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq, Copy)]
pub struct StrBuilder {
pub offset: usize,
pub length: usize,
@@ -146,12 +146,13 @@ pub trait StrBuild {
}
impl StrBuilder {
- fn display<'a>(&self, s: &'a [u8]) -> String {
+ pub fn display<'a>(&self, s: &'a [u8]) -> String {
let offset = self.offset;
let length = self.length;
String::from_utf8(s[offset..offset + length].to_vec()).unwrap()
}
- fn display_bytes<'a>(&self, b: &'a [u8]) -> &'a [u8] {
+
+ pub fn display_bytes<'a>(&self, b: &'a [u8]) -> &'a [u8] {
&b[self.offset..(self.offset + self.length)]
}
}