[][src]Trait hyper::header::Header

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

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

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.

Loading content...

Implementors

impl Header for AccessControlAllowOrigin[src]

impl Header for Expect[src]

impl Header for IfMatch[src]

impl Header for IfNoneMatch[src]

impl Header for IfRange[src]

impl Header for Pragma[src]

impl Header for Range[src]

impl Header for ReferrerPolicy[src]

impl Header for RetryAfter[src]

impl Header for Vary[src]

impl Header for Accept[src]

impl Header for AcceptCharset[src]

impl Header for AcceptEncoding[src]

impl Header for AcceptLanguage[src]

impl Header for AcceptRanges[src]

impl Header for AccessControlAllowCredentials[src]

impl Header for AccessControlAllowHeaders[src]

impl Header for AccessControlAllowMethods[src]

impl Header for AccessControlExposeHeaders[src]

impl Header for AccessControlMaxAge[src]

impl Header for AccessControlRequestHeaders[src]

impl Header for AccessControlRequestMethod[src]

impl Header for Allow[src]

impl Header for CacheControl[src]

impl Header for Connection[src]

impl Header for ContentDisposition[src]

impl Header for ContentEncoding[src]

impl Header for ContentLanguage[src]

impl Header for ContentLength[src]

impl Header for ContentLocation[src]

impl Header for ContentRange[src]

impl Header for ContentType[src]

impl Header for Cookie[src]

impl Header for Date[src]

impl Header for ETag[src]

impl Header for Expires[src]

impl Header for From[src]

impl Header for Host[src]

impl Header for IfModifiedSince[src]

impl Header for IfUnmodifiedSince[src]

impl Header for LastEventId[src]

impl Header for LastModified[src]

impl Header for Link[src]

impl Header for Location[src]

impl Header for Origin[src]

impl Header for Prefer[src]

impl Header for PreferenceApplied[src]

impl Header for Referer[src]

impl Header for Server[src]

impl Header for SetCookie[src]

impl Header for StrictTransportSecurity[src]

impl Header for Te[src]

impl Header for TransferEncoding[src]

impl Header for Upgrade[src]

impl Header for UserAgent[src]

impl Header for Warning[src]

impl<S: Scheme + Any> Header for Authorization<S> where
    <S as FromStr>::Err: 'static, 
[src]

impl<S: Scheme + Any> Header for ProxyAuthorization<S> where
    <S as FromStr>::Err: 'static, 
[src]

Loading content...