Struct rocket::http::Header [−][src]
Simple representation of an HTTP header.
Fields
name: Uncased<'h>
The name of the header.
value: Cow<'h, str>
The value of the header.
Methods
impl<'h> Header<'h>
[src]
impl<'h> Header<'h>
pub fn new<'a: 'h, 'b: 'h, N, V>(name: N, value: V) -> Header<'h> where
N: Into<Cow<'a, str>>,
V: Into<Cow<'b, str>>,
[src]
pub fn new<'a: 'h, 'b: 'h, N, V>(name: N, value: V) -> Header<'h> where
N: Into<Cow<'a, str>>,
V: Into<Cow<'b, str>>,
Constructs a new header. This method should be used rarely and only for
non-standard headers. Instead, prefer to use the Into<Header>
implementations of many types, including
ContentType and all of the headers in
http::hyper::header.
Examples
Create a custom header with name X-Custom-Header
and value custom value
.
use rocket::http::Header; let header = Header::new("X-Custom-Header", "custom value"); assert_eq!(header.to_string(), "X-Custom-Header: custom value");
Use a String
as a value to do the same.
use rocket::http::Header; let value = format!("{} value", "custom"); let header = Header::new("X-Custom-Header", value); assert_eq!(header.to_string(), "X-Custom-Header: custom value");
pub fn name(&self) -> &str
[src]
pub fn name(&self) -> &str
Returns the name of this header with casing preserved. To do a
case-insensitive equality check, use .name
directly.
Example
A case-sensitive equality check:
use rocket::http::Header; let value = format!("{} value", "custom"); let header = Header::new("X-Custom-Header", value); assert_eq!(header.name(), "X-Custom-Header"); assert!(header.name() != "X-CUSTOM-HEADER");
A case-insensitive equality check via .name
:
use rocket::http::Header; let header = Header::new("X-Custom-Header", "custom value"); assert_eq!(header.name, "X-Custom-Header"); assert_eq!(header.name, "X-CUSTOM-HEADER");
pub fn value(&self) -> &str
[src]
pub fn value(&self) -> &str
Returns the value of this header.
Example
A case-sensitive equality check:
use rocket::http::Header; let header = Header::new("X-Custom-Header", "custom value"); assert_eq!(header.value(), "custom value");
Trait Implementations
impl From<Accept> for Header<'static>
[src]
impl From<Accept> for Header<'static>
impl From<AccessControlAllowCredentials> for Header<'static>
[src]
impl From<AccessControlAllowCredentials> for Header<'static>
fn from(header: AccessControlAllowCredentials) -> Header<'static>
[src]
fn from(header: AccessControlAllowCredentials) -> Header<'static>
Performs the conversion.
impl From<AccessControlAllowHeaders> for Header<'static>
[src]
impl From<AccessControlAllowHeaders> for Header<'static>
fn from(header: AccessControlAllowHeaders) -> Header<'static>
[src]
fn from(header: AccessControlAllowHeaders) -> Header<'static>
Performs the conversion.
impl From<AccessControlAllowMethods> for Header<'static>
[src]
impl From<AccessControlAllowMethods> for Header<'static>
fn from(header: AccessControlAllowMethods) -> Header<'static>
[src]
fn from(header: AccessControlAllowMethods) -> Header<'static>
Performs the conversion.
impl From<AccessControlAllowOrigin> for Header<'static>
[src]
impl From<AccessControlAllowOrigin> for Header<'static>
fn from(header: AccessControlAllowOrigin) -> Header<'static>
[src]
fn from(header: AccessControlAllowOrigin) -> Header<'static>
Performs the conversion.
impl From<AccessControlExposeHeaders> for Header<'static>
[src]
impl From<AccessControlExposeHeaders> for Header<'static>
fn from(header: AccessControlExposeHeaders) -> Header<'static>
[src]
fn from(header: AccessControlExposeHeaders) -> Header<'static>
Performs the conversion.
impl From<AccessControlMaxAge> for Header<'static>
[src]
impl From<AccessControlMaxAge> for Header<'static>
fn from(header: AccessControlMaxAge) -> Header<'static>
[src]
fn from(header: AccessControlMaxAge) -> Header<'static>
Performs the conversion.
impl From<AccessControlRequestHeaders> for Header<'static>
[src]
impl From<AccessControlRequestHeaders> for Header<'static>
fn from(header: AccessControlRequestHeaders) -> Header<'static>
[src]
fn from(header: AccessControlRequestHeaders) -> Header<'static>
Performs the conversion.
impl From<AccessControlRequestMethod> for Header<'static>
[src]
impl From<AccessControlRequestMethod> for Header<'static>
fn from(header: AccessControlRequestMethod) -> Header<'static>
[src]
fn from(header: AccessControlRequestMethod) -> Header<'static>
Performs the conversion.
impl From<AcceptCharset> for Header<'static>
[src]
impl From<AcceptCharset> for Header<'static>
fn from(header: AcceptCharset) -> Header<'static>
[src]
fn from(header: AcceptCharset) -> Header<'static>
Performs the conversion.
impl From<AcceptEncoding> for Header<'static>
[src]
impl From<AcceptEncoding> for Header<'static>
fn from(header: AcceptEncoding) -> Header<'static>
[src]
fn from(header: AcceptEncoding) -> Header<'static>
Performs the conversion.
impl From<AcceptLanguage> for Header<'static>
[src]
impl From<AcceptLanguage> for Header<'static>
fn from(header: AcceptLanguage) -> Header<'static>
[src]
fn from(header: AcceptLanguage) -> Header<'static>
Performs the conversion.
impl From<AcceptRanges> for Header<'static>
[src]
impl From<AcceptRanges> for Header<'static>
fn from(header: AcceptRanges) -> Header<'static>
[src]
fn from(header: AcceptRanges) -> Header<'static>
Performs the conversion.
impl From<Allow> for Header<'static>
[src]
impl From<Allow> for Header<'static>
impl From<CacheControl> for Header<'static>
[src]
impl From<CacheControl> for Header<'static>
fn from(header: CacheControl) -> Header<'static>
[src]
fn from(header: CacheControl) -> Header<'static>
Performs the conversion.
impl From<Connection> for Header<'static>
[src]
impl From<Connection> for Header<'static>
fn from(header: Connection) -> Header<'static>
[src]
fn from(header: Connection) -> Header<'static>
Performs the conversion.
impl From<ContentDisposition> for Header<'static>
[src]
impl From<ContentDisposition> for Header<'static>
fn from(header: ContentDisposition) -> Header<'static>
[src]
fn from(header: ContentDisposition) -> Header<'static>
Performs the conversion.
impl From<ContentEncoding> for Header<'static>
[src]
impl From<ContentEncoding> for Header<'static>
fn from(header: ContentEncoding) -> Header<'static>
[src]
fn from(header: ContentEncoding) -> Header<'static>
Performs the conversion.
impl From<ContentLanguage> for Header<'static>
[src]
impl From<ContentLanguage> for Header<'static>
fn from(header: ContentLanguage) -> Header<'static>
[src]
fn from(header: ContentLanguage) -> Header<'static>
Performs the conversion.
impl From<ContentLength> for Header<'static>
[src]
impl From<ContentLength> for Header<'static>
fn from(header: ContentLength) -> Header<'static>
[src]
fn from(header: ContentLength) -> Header<'static>
Performs the conversion.
impl From<ContentRange> for Header<'static>
[src]
impl From<ContentRange> for Header<'static>
fn from(header: ContentRange) -> Header<'static>
[src]
fn from(header: ContentRange) -> Header<'static>
Performs the conversion.
impl From<Date> for Header<'static>
[src]
impl From<Date> for Header<'static>
impl From<ETag> for Header<'static>
[src]
impl From<ETag> for Header<'static>
impl From<Expect> for Header<'static>
[src]
impl From<Expect> for Header<'static>
impl From<Expires> for Header<'static>
[src]
impl From<Expires> for Header<'static>
impl From<Host> for Header<'static>
[src]
impl From<Host> for Header<'static>
impl From<IfMatch> for Header<'static>
[src]
impl From<IfMatch> for Header<'static>
impl From<IfModifiedSince> for Header<'static>
[src]
impl From<IfModifiedSince> for Header<'static>
fn from(header: IfModifiedSince) -> Header<'static>
[src]
fn from(header: IfModifiedSince) -> Header<'static>
Performs the conversion.
impl From<IfNoneMatch> for Header<'static>
[src]
impl From<IfNoneMatch> for Header<'static>
fn from(header: IfNoneMatch) -> Header<'static>
[src]
fn from(header: IfNoneMatch) -> Header<'static>
Performs the conversion.
impl From<IfRange> for Header<'static>
[src]
impl From<IfRange> for Header<'static>
impl From<IfUnmodifiedSince> for Header<'static>
[src]
impl From<IfUnmodifiedSince> for Header<'static>
fn from(header: IfUnmodifiedSince) -> Header<'static>
[src]
fn from(header: IfUnmodifiedSince) -> Header<'static>
Performs the conversion.
impl From<LastModified> for Header<'static>
[src]
impl From<LastModified> for Header<'static>
fn from(header: LastModified) -> Header<'static>
[src]
fn from(header: LastModified) -> Header<'static>
Performs the conversion.
impl From<Location> for Header<'static>
[src]
impl From<Location> for Header<'static>
impl From<Origin> for Header<'static>
[src]
impl From<Origin> for Header<'static>
impl From<Pragma> for Header<'static>
[src]
impl From<Pragma> for Header<'static>
impl From<Prefer> for Header<'static>
[src]
impl From<Prefer> for Header<'static>
impl From<PreferenceApplied> for Header<'static>
[src]
impl From<PreferenceApplied> for Header<'static>
fn from(header: PreferenceApplied) -> Header<'static>
[src]
fn from(header: PreferenceApplied) -> Header<'static>
Performs the conversion.
impl From<Range> for Header<'static>
[src]
impl From<Range> for Header<'static>
impl From<Referer> for Header<'static>
[src]
impl From<Referer> for Header<'static>
impl From<ReferrerPolicy> for Header<'static>
[src]
impl From<ReferrerPolicy> for Header<'static>
fn from(header: ReferrerPolicy) -> Header<'static>
[src]
fn from(header: ReferrerPolicy) -> Header<'static>
Performs the conversion.
impl From<StrictTransportSecurity> for Header<'static>
[src]
impl From<StrictTransportSecurity> for Header<'static>
fn from(header: StrictTransportSecurity) -> Header<'static>
[src]
fn from(header: StrictTransportSecurity) -> Header<'static>
Performs the conversion.
impl From<TransferEncoding> for Header<'static>
[src]
impl From<TransferEncoding> for Header<'static>
fn from(header: TransferEncoding) -> Header<'static>
[src]
fn from(header: TransferEncoding) -> Header<'static>
Performs the conversion.
impl From<Upgrade> for Header<'static>
[src]
impl From<Upgrade> for Header<'static>
impl From<UserAgent> for Header<'static>
[src]
impl From<UserAgent> for Header<'static>
impl From<Vary> for Header<'static>
[src]
impl From<Vary> for Header<'static>
impl<'a, 'c> From<&'a Cookie<'c>> for Header<'static>
[src]
impl<'a, 'c> From<&'a Cookie<'c>> for Header<'static>
impl Into<Header<'static>> for ContentType
[src]
impl Into<Header<'static>> for ContentType
Creates a new Header
with name Content-Type
and the value set to the
HTTP rendering of this Content-Type.
impl<'h> Debug for Header<'h>
[src]
impl<'h> Debug for Header<'h>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'h> Clone for Header<'h>
[src]
impl<'h> Clone for Header<'h>
fn clone(&self) -> Header<'h>
[src]
fn clone(&self) -> Header<'h>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'h> Hash for Header<'h>
[src]
impl<'h> Hash for Header<'h>
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'h> PartialEq for Header<'h>
[src]
impl<'h> PartialEq for Header<'h>
fn eq(&self, other: &Header<'h>) -> bool
[src]
fn eq(&self, other: &Header<'h>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Header<'h>) -> bool
[src]
fn ne(&self, other: &Header<'h>) -> bool
This method tests for !=
.
impl<'h> Eq for Header<'h>
[src]
impl<'h> Eq for Header<'h>
impl<'h> Display for Header<'h>
[src]
impl<'h> Display for Header<'h>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Into<Header<'static>> for Accept
[src]
impl Into<Header<'static>> for Accept
Creates a new Header
with name Accept
and the value set to the HTTP
rendering of this Accept
header.