#[non_exhaustive]pub struct ParsedHeader {
pub name: String,
pub value: String,
pub raw_value: Vec<u8>,
}Expand description
A decoded RFC 5322 / MIME header field.
For headers whose value mail-parser parses as plain text (Subject,
Comments, Content-Description, and any unstructured header), value
contains the fully decoded Unicode string (RFC 2047 encoded-words are
already resolved).
For all other header types (Address, DateTime, ContentType,
Received), value is the raw bytes sliced from the original message
and converted with String::from_utf8_lossy. These structured values
require their own dedicated parsers — see
parse_header_typed.
raw_value always contains the original bytes of the header field
value from the wire message (the portion after the : separator).
Use raw_value — not value.as_bytes() — when feeding a header
into parse_header_typed, because
value may have undergone lossy UTF-8 conversion for structured
headers.
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.name: StringHeader field name (e.g. "From", "Subject").
value: StringDecoded or lossy-converted header field value as a UTF-8 string.
For text headers, this is the fully decoded value (RFC 2047 encoded-words resolved). For structured headers, this is a lossy UTF-8 conversion of the raw bytes — non-UTF-8 bytes are replaced with U+FFFD.
raw_value: Vec<u8>Raw bytes of the header field value from the original message.
This is the byte sequence after the : separator, preserving the
original encoding without lossy UTF-8 conversion. For accurate
typed parsing, always use these bytes with
parse_header_typed rather than
value.as_bytes().
Trait Implementations§
Source§impl Clone for ParsedHeader
impl Clone for ParsedHeader
Source§fn clone(&self) -> ParsedHeader
fn clone(&self) -> ParsedHeader
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 ParsedHeader
impl Debug for ParsedHeader
Source§impl<'de> Deserialize<'de> for ParsedHeader
impl<'de> Deserialize<'de> for ParsedHeader
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 ParsedHeader
Source§impl PartialEq for ParsedHeader
impl PartialEq for ParsedHeader
Source§fn eq(&self, other: &ParsedHeader) -> bool
fn eq(&self, other: &ParsedHeader) -> bool
self and other values to be equal, and is used by ==.