#[non_exhaustive]pub struct Header { /* private fields */ }Expand description
A single message header line.
Implementations§
Source§impl Header
impl Header
pub fn name(&self) -> &str
pub fn value(&self) -> &str
Sourcepub fn new(
name: impl Into<String>,
value: impl Into<String>,
) -> Result<Self, HeaderValidationError>
pub fn new( name: impl Into<String>, value: impl Into<String>, ) -> Result<Self, HeaderValidationError>
Constructs a header after validating name and value.
§Name validation
The name must be non-empty and use only the RFC 5322 §2.2 ftext
byte range (0x21..=0x39 | 0x3B..=0x7E). That is the literal
grammar definition: it admits punctuation such as @, (, ),
,, <, >, [, ], ?, =, \, ". Conventional header
names use the narrower RFC 7230 §3.2.6 token shape (alphanumerics
plus a small punctuation set). Real MTAs and provider HTTP-header
maps reject the looser superset; if you produce non-token names
here the message will still pass kernel validation but will be
dropped or routed to spam by most receivers. Callers needing the
token shape should validate themselves before calling this
constructor.
§Errors
Returns HeaderValidationError when the name uses bytes outside
the RFC 5322 set or the value contains raw newlines or
non-tab control characters.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for Header
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for Header
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for Header
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Header
serde only.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 JsonSchema for Header
impl JsonSchema for Header
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more