#[non_exhaustive]pub struct ParsedPart {
pub part_id: String,
pub content_type: String,
pub charset: Option<String>,
pub transfer_encoding: TransferEncoding,
pub disposition: Option<String>,
pub filename: Option<String>,
pub cid: Option<String>,
pub header_range: (u32, u32),
pub body_range: (u32, u32),
pub children: Vec<ParsedPart>,
pub is_encoding_problem: bool,
}Expand description
A single MIME part in the parsed tree.
Byte ranges (header_range, body_range) are (offset, length) indices
into the caller’s original &[u8]. The crate never stores raw bytes.
Both fields use u32 to guarantee identical serialized representation on
32-bit and 64-bit hosts. RFC 5321 recommends a 10 MB message size limit;
the 4 GiB u32 range covers all realistic messages. Callers processing
raw input exceeding 4 GiB MUST reject it before calling parse
— mail-parser uses usize offsets internally and parse truncates them
to u32 via saturating_sub, which would produce incorrect byte ranges
without error on oversized input.
For multipart/* parts, children is non-empty and body_range covers
the entire multipart body including boundaries.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.part_id: StringIMAP dotted-path part ID: "1", "1.1", "1.2", etc.
content_type: StringContent-Type media type/subtype (e.g. "text/plain").
charset: Option<String>Charset parameter from Content-Type, if present.
None means no explicit charset= parameter was present on the
Content-Type header. Per RFC 2045 §5.2 the default is US-ASCII, but
decode_body_value() defaults to UTF-8 instead (a strict superset)
for better handling of the modern email corpus.
transfer_encoding: TransferEncodingContent-Transfer-Encoding.
disposition: Option<String>Content-Disposition value (e.g. "attachment", "inline").
filename: Option<String>Filename from Content-Disposition or Content-Type.
cid: Option<String>Content-ID header value, if present.
header_range: (u32, u32)(offset, length) of this part’s headers in the original bytes.
To access individual typed headers for a part, slice
raw[offset..offset+length] and pass the result to
parse_header_typed.
body_range: (u32, u32)(offset, length) of this part’s body (pre-decode) in the original bytes.
children: Vec<ParsedPart>Child parts. Non-empty only for multipart/* content types.
is_encoding_problem: boolTrue if mail-parser flagged this part as having a structural encoding problem (e.g., invalid base64 padding in the raw transfer encoding).
This is a parse-time flag, distinct from
[DecodedBodyValue::is_encoding_problem] which is set during
charset conversion in decode_body_value().
Implementations§
Source§impl ParsedPart
impl ParsedPart
Sourcepub fn find_by_id(&self, id: &str) -> Option<&ParsedPart>
pub fn find_by_id(&self, id: &str) -> Option<&ParsedPart>
Find a descendant part by its dotted IMAP part ID.
Searches this part and all descendants depth-first. Returns None if
no part with the given ID exists in the tree.
§Part ID conventions
- Non-multipart root: the root part has
part_id = "1". - Multipart root: the root part has
part_id = ""(empty string); its children are"1","2", etc. - Nested multipart: children use dotted paths like
"1.1","1.2".
// Non-multipart: root is "1"
let raw = b"Content-Type: text/plain\r\n\r\nHello\r\n";
let msg = parse(raw).unwrap();
let part = msg.part_index.find_by_id("1").unwrap();
assert_eq!(part.content_type, "text/plain");Trait Implementations§
Source§impl Clone for ParsedPart
impl Clone for ParsedPart
Source§fn clone(&self) -> ParsedPart
fn clone(&self) -> ParsedPart
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ParsedPart
impl Debug for ParsedPart
Source§impl<'de> Deserialize<'de> for ParsedPart
impl<'de> Deserialize<'de> for ParsedPart
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ParsedPart
Source§impl PartialEq for ParsedPart
impl PartialEq for ParsedPart
Source§fn eq(&self, other: &ParsedPart) -> bool
fn eq(&self, other: &ParsedPart) -> bool
self and other values to be equal, and is used by ==.