mirror of
https://github.com/stalwartlabs/mail-parser.git
synced 2026-11-29 00:01:49 +00:00
Renamed header offset fields.
This commit is contained in:
+8
-7
@@ -403,8 +403,8 @@ impl<'x> Group<'x> {
|
||||
pub struct Header<'x> {
|
||||
pub name: HeaderName<'x>,
|
||||
pub value: HeaderValue<'x>,
|
||||
pub raw_start: usize,
|
||||
pub raw_end: usize,
|
||||
pub offset_start: usize,
|
||||
pub offset_end: usize,
|
||||
}
|
||||
|
||||
impl<'x> Header<'x> {
|
||||
@@ -420,12 +420,12 @@ impl<'x> Header<'x> {
|
||||
|
||||
/// Returns the raw offset start
|
||||
pub fn offset_start(&self) -> usize {
|
||||
self.raw_start
|
||||
self.offset_start
|
||||
}
|
||||
|
||||
/// Returns the raw offset end
|
||||
pub fn offset_end(&self) -> usize {
|
||||
self.raw_end
|
||||
self.offset_end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -765,7 +765,7 @@ impl<'x> Message<'x> {
|
||||
self.parts[0]
|
||||
.headers
|
||||
.get_header(header)
|
||||
.and_then(|h| std::str::from_utf8(&self.raw_message[h.raw_start..h.raw_end]).ok())
|
||||
.and_then(|h| std::str::from_utf8(&self.raw_message[h.offset_start..h.offset_end]).ok())
|
||||
}
|
||||
|
||||
/// Returns an iterator over the RFC headers of this message.
|
||||
@@ -778,7 +778,8 @@ impl<'x> Message<'x> {
|
||||
self.parts[0].headers.iter().filter_map(move |header| {
|
||||
Some((
|
||||
header.name.as_str(),
|
||||
std::str::from_utf8(&self.raw_message[header.raw_start..header.raw_end]).ok()?,
|
||||
std::str::from_utf8(&self.raw_message[header.offset_start..header.offset_end])
|
||||
.ok()?,
|
||||
))
|
||||
})
|
||||
}
|
||||
@@ -1310,7 +1311,7 @@ impl<'x> MessagePart<'x> {
|
||||
}
|
||||
|
||||
/// Get the raw body end offset of this part
|
||||
pub fn raw_end_offset(&self) -> usize {
|
||||
pub fn offset_end_offset(&self) -> usize {
|
||||
self.offset_header
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,8 @@ pub fn parse_headers<'x>(headers: &mut Vec<Header<'x>>, stream: &mut MessageStre
|
||||
headers.push(Header {
|
||||
name: HeaderName::Rfc(name),
|
||||
value: parser(stream),
|
||||
raw_start: from_offset,
|
||||
raw_end: stream.pos,
|
||||
offset_start: from_offset,
|
||||
offset_end: stream.pos,
|
||||
});
|
||||
}
|
||||
HeaderParserResult::Other(name) => {
|
||||
@@ -60,8 +60,8 @@ pub fn parse_headers<'x>(headers: &mut Vec<Header<'x>>, stream: &mut MessageStre
|
||||
value: HeaderValue::Text(String::from_utf8_lossy(
|
||||
&stream.data[from_offset..stream.pos],
|
||||
)),
|
||||
raw_start: from_offset,
|
||||
raw_end: stream.pos,
|
||||
offset_start: from_offset,
|
||||
offset_end: stream.pos,
|
||||
});
|
||||
}
|
||||
HeaderParserResult::Lf => return true,
|
||||
|
||||
Reference in New Issue
Block a user