Trait hyper::header::Header
[−]
[src]
pub trait Header: 'static + HeaderClone + Send + Sync { fn header_name() -> &'static str
where
Self: Sized; fn parse_header(raw: &Raw) -> Result<Self>
where
Self: Sized; fn fmt_header(&self, f: &mut Formatter) -> Result; }
A trait for any object that will represent a header field and value.
This trait represents the construction and identification of headers, and contains trait-object unsafe methods.
Required Methods
fn header_name() -> &'static str where
Self: Sized,
Self: Sized,
Returns the name of the header field this belongs to.
This will become an associated constant once available.
fn parse_header(raw: &Raw) -> Result<Self> where
Self: Sized,
Self: Sized,
Parse a header from a raw stream of bytes.
It's possible that a request can include a header field more than once,
and in that case, the slice will have a length greater than 1. However,
it's not necessarily the case that a Header is allowed to have more
than one field value. If that's the case, you should return None
if raw.len() > 1
.
fn fmt_header(&self, f: &mut Formatter) -> Result
Format a header to outgoing stream.
Most headers should be formatted on one line, and so a common pattern
would be to implement std::fmt::Display
for this type as well, and
then just call f.fmt_line(self)
.
Note
This has the ability to format a header over multiple lines.
The main example here is Set-Cookie
, which requires that every
cookie being set be specified in a separate line. Almost every other
case should only format as 1 single line.
Implementors
impl Header for AcceptCharset
impl Header for AcceptEncoding
impl Header for AcceptLanguage
impl Header for AcceptRanges
impl Header for Accept
impl Header for AccessControlAllowCredentials
impl Header for AccessControlAllowHeaders
impl Header for AccessControlAllowMethods
impl Header for AccessControlAllowOrigin
impl Header for AccessControlExposeHeaders
impl Header for AccessControlMaxAge
impl Header for AccessControlRequestHeaders
impl Header for AccessControlRequestMethod
impl Header for Allow
impl<S: Scheme + Any> Header for Authorization<S> where
<S as FromStr>::Err: 'static,impl Header for CacheControl
impl Header for Connection
impl Header for ContentDisposition
impl Header for ContentEncoding
impl Header for ContentLanguage
impl Header for ContentLength
impl Header for ContentLocation
impl Header for ContentRange
impl Header for ContentType
impl Header for Cookie
impl Header for Date
impl Header for ETag
impl Header for Expect
impl Header for Expires
impl Header for From
impl Header for Host
impl Header for IfMatch
impl Header for IfModifiedSince
impl Header for IfNoneMatch
impl Header for IfRange
impl Header for IfUnmodifiedSince
impl Header for LastEventId
impl Header for LastModified
impl Header for Link
impl Header for Location
impl Header for Origin
impl Header for Pragma
impl Header for Prefer
impl Header for PreferenceApplied
impl Header for Range
impl Header for Referer
impl Header for ReferrerPolicy
impl Header for RetryAfter
impl Header for Server
impl Header for SetCookie
impl Header for StrictTransportSecurity
impl Header for Te
impl Header for TransferEncoding
impl Header for Upgrade
impl Header for UserAgent
impl Header for Vary
impl Header for Warning