#[non_exhaustive]pub struct HeaderName(/* private fields */);Expand description
A validated RFC 5322 header field name.
RFC 5322 Section 2.2 defines a field name as 1*ftext, where
ftext = %d33-57 / %d59-126 — printable US-ASCII excluding the colon
(:). This newtype enforces that constraint at construction time so
that downstream code can rely on the name being well-formed.
§Case Insensitivity
Comparison and hashing are case-insensitive per RFC 5322 Section 2.2,
so HeaderName::new("Subject") and HeaderName::new("subject") are equal.
§References
- RFC 5322 Section 2.2 (header field syntax)
Implementations§
Source§impl HeaderName
impl HeaderName
Sourcepub fn new(s: impl Into<String>) -> Result<Self>
pub fn new(s: impl Into<String>) -> Result<Self>
Creates a new HeaderName after validating ftext syntax
(RFC 5322 Section 2.2).
The name must be non-empty and consist solely of printable US-ASCII characters (33..=126) excluding colon (58).
§Errors
Returns crate::error::Error::InvalidHeaderName if the name is
empty or contains invalid characters.
§References
- RFC 5322 Section 2.2
Sourcepub fn into_inner(self) -> String
pub fn into_inner(self) -> String
Consumes self and returns the inner String.
Trait Implementations§
Source§impl AsRef<str> for HeaderName
impl AsRef<str> for HeaderName
Source§impl Clone for HeaderName
impl Clone for HeaderName
Source§fn clone(&self) -> HeaderName
fn clone(&self) -> HeaderName
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HeaderName
impl Debug for HeaderName
Source§impl Display for HeaderName
impl Display for HeaderName
Source§impl From<HeaderName> for String
impl From<HeaderName> for String
Source§fn from(h: HeaderName) -> Self
fn from(h: HeaderName) -> Self
Source§impl Hash for HeaderName
Hash header names case-insensitively so hashing matches equality.
impl Hash for HeaderName
Hash header names case-insensitively so hashing matches equality.
RFC 822 Section 3.4.7: field-name case is not distinguished. RFC 5322 continues the same header field model.
Source§impl Ord for HeaderName
Total ordering on header names, case-insensitive (RFC 5322 Section 2.2).
impl Ord for HeaderName
Total ordering on header names, case-insensitive (RFC 5322 Section 2.2).
Source§impl PartialEq for HeaderName
Internet message field names are case-insensitive during comparison.
impl PartialEq for HeaderName
Internet message field names are case-insensitive during comparison.
RFC 822 Section 3.4.7 states this rule explicitly, and RFC 5322 retains
the same field-name model for message headers.
Source§impl PartialOrd for HeaderName
Order header names case-insensitively (RFC 5322 Section 2.2).
impl PartialOrd for HeaderName
Order header names case-insensitively (RFC 5322 Section 2.2).