#[non_exhaustive]pub enum HeaderForm {
Raw,
Text,
Addresses,
GroupedAddresses,
MessageIds,
Date,
URLs,
}Expand description
Selector for the RFC 8621 parsed-form of a header value.
This is the form-token from a JMAP header:<name>:as<form> property
selector, normalised to an enum.
Display emits the canonical JMAP form-token string
(asRaw, asAddresses, …, asURLs).
FromStr accepts exactly that set of strings;
any other input yields UnknownHeaderForm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Raw
Trim surrounding whitespace; return the bytes as a UTF-8 string. (§4.1.2.1)
Non-UTF-8 bytes — legal in raw RFC 5322 but not in JMAP wire format — are replaced with U+FFFD REPLACEMENT CHARACTER (lossy conversion). This preserves the position and rough shape of malformed input so callers can flag a mojibake header without losing the rest of the field body.
Text
RFC 8621 §4.1.2.2 Text form. Unfold whitespace, strip the trailing CRLF and leading SP, decode all syntactically-correct RFC 2047 encoded-words, then Unicode-normalise the result to NFC.
This is the form most commonly used by JMAP clients fetching human-readable header fields like Subject, Comments, Keywords, and List-Id.
Addresses
Parse as an RFC 5322 address-list. Group structure is discarded;
only the flat list of mailboxes is returned. (§4.1.2.3)
GroupedAddresses
Parse as an RFC 5322 address-list, preserving group structure.
(§4.1.2.4)
MessageIds
Parse as a list of RFC 5322 msg-id values. Surrounding angle
brackets and CFWS are stripped. (§4.1.2.5)
Date
Parse as an RFC 5322 §3.3 date-time. (§4.1.2.6)
URLs
Parse as an RFC 2369 list of URLs. Surrounding angle brackets and comments are stripped. (§4.1.2.7)
Implementations§
Source§impl HeaderForm
impl HeaderForm
Sourcepub fn as_jmap_token(&self) -> &'static str
pub fn as_jmap_token(&self) -> &'static str
Return the canonical RFC 8621 §4.1.2 form-token string for this variant.
The token starts with as (the convention used in JMAP property
selectors such as header:Subject:asText). Inverse of
HeaderForm’s FromStr impl.
Trait Implementations§
Source§impl Clone for HeaderForm
impl Clone for HeaderForm
Source§fn clone(&self) -> HeaderForm
fn clone(&self) -> HeaderForm
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 HeaderForm
impl Debug for HeaderForm
Source§impl<'de> Deserialize<'de> for HeaderForm
impl<'de> Deserialize<'de> for HeaderForm
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>,
Source§impl Display for HeaderForm
impl Display for HeaderForm
impl Eq for HeaderForm
Source§impl FromStr for HeaderForm
impl FromStr for HeaderForm
Source§impl Hash for HeaderForm
impl Hash for HeaderForm
Source§impl PartialEq for HeaderForm
impl PartialEq for HeaderForm
Source§fn eq(&self, other: &HeaderForm) -> bool
fn eq(&self, other: &HeaderForm) -> bool
self and other values to be equal, and is used by ==.