pub struct MimePart {
pub headers: Headers,
pub body: Vec<u8>,
}Expand description
A single part from a multipart MIME body.
Fields§
§headers: HeadersPart headers in wire order (e.g., Content-Type, Content-ID).
body: Vec<u8>Part body bytes.
Implementations§
Source§impl MimePart
impl MimePart
Sourcepub fn media_type(&self) -> Option<Cow<'_, str>>
pub fn media_type(&self) -> Option<Cow<'_, str>>
Content-Type with parameters stripped and lowercased, e.g.
application/sdp from Application/SDP; charset=utf-8. Use this to
dispatch on the type rather than matching the raw header value.
Sourcepub fn is_multipart(&self) -> bool
pub fn is_multipart(&self) -> bool
Returns true if this part’s Content-Type starts with multipart/.
Sourcepub fn multipart_boundary(&self) -> Option<&str>
pub fn multipart_boundary(&self) -> Option<&str>
Extract the MIME boundary string from this part’s Content-Type header.
Sourcepub fn parse_sipfrag(&self) -> Result<SipFragment, ParseError>
pub fn parse_sipfrag(&self) -> Result<SipFragment, ParseError>
Parse this part’s body as a message/sipfrag (RFC 3420).
Does not check the Content-Type: dispatch on media_type
first, then call this for the parts that claim to be fragments.
Sourcepub fn body_parts(&self) -> Option<Vec<MimePart>>
pub fn body_parts(&self) -> Option<Vec<MimePart>>
Split a nested multipart part into its own MimeParts.
Returns None when this part carries no boundary or that boundary
yields no parts — either way, keep the part’s own bytes.
Descends exactly one level: a grandchild multipart comes back as a part
with its multipart/* type intact, to be split by another explicit
call. Depth is the caller’s decision.
Source§impl MimePart
impl MimePart
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Returns the Content-Type header value, if present.
Sourcepub fn header_value(&self, name: &str) -> Option<&str>
pub fn header_value(&self, name: &str) -> Option<&str>
Case-insensitive header lookup, first match in wire order.
Sourcepub fn content_id(&self) -> Option<&str>
pub fn content_id(&self) -> Option<&str>
Returns the Content-ID header value, if present.
Sourcepub fn content_disposition(&self) -> Option<&str>
pub fn content_disposition(&self) -> Option<&str>
Returns the Content-Disposition header value, if present.
Sourcepub fn content_transfer_encoding(&self) -> Option<&str>
pub fn content_transfer_encoding(&self) -> Option<&str>
Returns the Content-Transfer-Encoding header value, if present. A value the caller does not recognize means the part’s bytes are not what its media type describes.