hyper_old_types::header

Trait Header

Source
pub trait Header:
    'static
    + HeaderClone
    + Send
    + Sync {
    // Required methods
    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;
}
Expand description

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§

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Box<dyn Header + Send + Sync>

Source§

fn clone(&self) -> Box<dyn Header + Send + Sync>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§

Source§

impl Header for AccessControlAllowOrigin

Source§

impl Header for Expect

Source§

impl Header for IfMatch

Source§

impl Header for IfNoneMatch

Source§

impl Header for IfRange

Source§

impl Header for Pragma

Source§

impl Header for Range

Source§

impl Header for ReferrerPolicy

Source§

impl Header for RetryAfter

Source§

impl Header for Vary

Source§

impl Header for Accept

Source§

impl Header for AcceptCharset

Source§

impl Header for AcceptEncoding

Source§

impl Header for AcceptLanguage

Source§

impl Header for AcceptRanges

Source§

impl Header for AccessControlAllowCredentials

Source§

impl Header for AccessControlAllowHeaders

Source§

impl Header for AccessControlAllowMethods

Source§

impl Header for AccessControlExposeHeaders

Source§

impl Header for AccessControlMaxAge

Source§

impl Header for AccessControlRequestHeaders

Source§

impl Header for AccessControlRequestMethod

Source§

impl Header for Allow

Source§

impl Header for CacheControl

Source§

impl Header for Connection

Source§

impl Header for ContentDisposition

Source§

impl Header for ContentEncoding

Source§

impl Header for ContentLanguage

Source§

impl Header for ContentLength

Source§

impl Header for ContentLocation

Source§

impl Header for ContentRange

Source§

impl Header for ContentType

Source§

impl Header for Date

Source§

impl Header for ETag

Source§

impl Header for Expires

Source§

impl Header for From

Source§

impl Header for Host

Source§

impl Header for IfModifiedSince

Source§

impl Header for IfUnmodifiedSince

Source§

impl Header for LastEventId

Source§

impl Header for LastModified

Source§

impl Header for Location

Source§

impl Header for Origin

Source§

impl Header for Prefer

Source§

impl Header for PreferenceApplied

Source§

impl Header for Referer

Source§

impl Header for Server

Source§

impl Header for SetCookie

Source§

impl Header for StrictTransportSecurity

Source§

impl Header for Te

Source§

impl Header for TransferEncoding

Source§

impl Header for Upgrade

Source§

impl Header for UserAgent

Source§

impl Header for Warning

Source§

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

Source§

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