Struct rocket_http::Header [−][src]
Expand description
Simple representation of an HTTP header.
Fields
name: Uncased<'h>
The name of the header.
value: Cow<'h, str>
The value of the header.
Implementations
impl<'h> Header<'h>
[src]
impl<'h> Header<'h>
[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>>,
[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>>,
[src]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
[src]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");
Trait Implementations
impl From<AcceptCharset> for Header<'static>
[src]
impl From<AcceptCharset> for Header<'static>
[src]fn from(header: AcceptCharset) -> Header<'static>
[src]
fn from(header: AcceptCharset) -> Header<'static>
[src]Performs the conversion.
impl From<AcceptEncoding> for Header<'static>
[src]
impl From<AcceptEncoding> for Header<'static>
[src]fn from(header: AcceptEncoding) -> Header<'static>
[src]
fn from(header: AcceptEncoding) -> Header<'static>
[src]Performs the conversion.
impl From<AcceptLanguage> for Header<'static>
[src]
impl From<AcceptLanguage> for Header<'static>
[src]fn from(header: AcceptLanguage) -> Header<'static>
[src]
fn from(header: AcceptLanguage) -> Header<'static>
[src]Performs the conversion.
impl From<AcceptRanges> for Header<'static>
[src]
impl From<AcceptRanges> for Header<'static>
[src]fn from(header: AcceptRanges) -> Header<'static>
[src]
fn from(header: AcceptRanges) -> Header<'static>
[src]Performs the conversion.
impl From<AccessControlAllowCredentials> for Header<'static>
[src]
impl From<AccessControlAllowCredentials> for Header<'static>
[src]fn from(header: AccessControlAllowCredentials) -> Header<'static>
[src]
fn from(header: AccessControlAllowCredentials) -> Header<'static>
[src]Performs the conversion.
impl From<AccessControlAllowHeaders> for Header<'static>
[src]
impl From<AccessControlAllowHeaders> for Header<'static>
[src]fn from(header: AccessControlAllowHeaders) -> Header<'static>
[src]
fn from(header: AccessControlAllowHeaders) -> Header<'static>
[src]Performs the conversion.
impl From<AccessControlAllowMethods> for Header<'static>
[src]
impl From<AccessControlAllowMethods> for Header<'static>
[src]fn from(header: AccessControlAllowMethods) -> Header<'static>
[src]
fn from(header: AccessControlAllowMethods) -> Header<'static>
[src]Performs the conversion.
impl From<AccessControlAllowOrigin> for Header<'static>
[src]
impl From<AccessControlAllowOrigin> for Header<'static>
[src]fn from(header: AccessControlAllowOrigin) -> Header<'static>
[src]
fn from(header: AccessControlAllowOrigin) -> Header<'static>
[src]Performs the conversion.
impl From<AccessControlExposeHeaders> for Header<'static>
[src]
impl From<AccessControlExposeHeaders> for Header<'static>
[src]fn from(header: AccessControlExposeHeaders) -> Header<'static>
[src]
fn from(header: AccessControlExposeHeaders) -> Header<'static>
[src]Performs the conversion.
impl From<AccessControlMaxAge> for Header<'static>
[src]
impl From<AccessControlMaxAge> for Header<'static>
[src]fn from(header: AccessControlMaxAge) -> Header<'static>
[src]
fn from(header: AccessControlMaxAge) -> Header<'static>
[src]Performs the conversion.
impl From<AccessControlRequestHeaders> for Header<'static>
[src]
impl From<AccessControlRequestHeaders> for Header<'static>
[src]fn from(header: AccessControlRequestHeaders) -> Header<'static>
[src]
fn from(header: AccessControlRequestHeaders) -> Header<'static>
[src]Performs the conversion.
impl From<AccessControlRequestMethod> for Header<'static>
[src]
impl From<AccessControlRequestMethod> for Header<'static>
[src]fn from(header: AccessControlRequestMethod) -> Header<'static>
[src]
fn from(header: AccessControlRequestMethod) -> Header<'static>
[src]Performs the conversion.
impl From<CacheControl> for Header<'static>
[src]
impl From<CacheControl> for Header<'static>
[src]fn from(header: CacheControl) -> Header<'static>
[src]
fn from(header: CacheControl) -> Header<'static>
[src]Performs the conversion.
impl From<Connection> for Header<'static>
[src]
impl From<Connection> for Header<'static>
[src]fn from(header: Connection) -> Header<'static>
[src]
fn from(header: Connection) -> Header<'static>
[src]Performs the conversion.
impl From<ContentDisposition> for Header<'static>
[src]
impl From<ContentDisposition> for Header<'static>
[src]fn from(header: ContentDisposition) -> Header<'static>
[src]
fn from(header: ContentDisposition) -> Header<'static>
[src]Performs the conversion.
impl From<ContentEncoding> for Header<'static>
[src]
impl From<ContentEncoding> for Header<'static>
[src]fn from(header: ContentEncoding) -> Header<'static>
[src]
fn from(header: ContentEncoding) -> Header<'static>
[src]Performs the conversion.
impl From<ContentLanguage> for Header<'static>
[src]
impl From<ContentLanguage> for Header<'static>
[src]fn from(header: ContentLanguage) -> Header<'static>
[src]
fn from(header: ContentLanguage) -> Header<'static>
[src]Performs the conversion.
impl From<ContentLength> for Header<'static>
[src]
impl From<ContentLength> for Header<'static>
[src]fn from(header: ContentLength) -> Header<'static>
[src]
fn from(header: ContentLength) -> Header<'static>
[src]Performs the conversion.
impl From<ContentRange> for Header<'static>
[src]
impl From<ContentRange> for Header<'static>
[src]fn from(header: ContentRange) -> Header<'static>
[src]
fn from(header: ContentRange) -> Header<'static>
[src]Performs the conversion.
impl From<IfModifiedSince> for Header<'static>
[src]
impl From<IfModifiedSince> for Header<'static>
[src]fn from(header: IfModifiedSince) -> Header<'static>
[src]
fn from(header: IfModifiedSince) -> Header<'static>
[src]Performs the conversion.
impl From<IfNoneMatch> for Header<'static>
[src]
impl From<IfNoneMatch> for Header<'static>
[src]fn from(header: IfNoneMatch) -> Header<'static>
[src]
fn from(header: IfNoneMatch) -> Header<'static>
[src]Performs the conversion.
impl From<IfUnmodifiedSince> for Header<'static>
[src]
impl From<IfUnmodifiedSince> for Header<'static>
[src]fn from(header: IfUnmodifiedSince) -> Header<'static>
[src]
fn from(header: IfUnmodifiedSince) -> Header<'static>
[src]Performs the conversion.
impl From<LastModified> for Header<'static>
[src]
impl From<LastModified> for Header<'static>
[src]fn from(header: LastModified) -> Header<'static>
[src]
fn from(header: LastModified) -> Header<'static>
[src]Performs the conversion.
impl From<PreferenceApplied> for Header<'static>
[src]
impl From<PreferenceApplied> for Header<'static>
[src]fn from(header: PreferenceApplied) -> Header<'static>
[src]
fn from(header: PreferenceApplied) -> Header<'static>
[src]Performs the conversion.
impl From<ReferrerPolicy> for Header<'static>
[src]
impl From<ReferrerPolicy> for Header<'static>
[src]fn from(header: ReferrerPolicy) -> Header<'static>
[src]
fn from(header: ReferrerPolicy) -> Header<'static>
[src]Performs the conversion.
impl From<StrictTransportSecurity> for Header<'static>
[src]
impl From<StrictTransportSecurity> for Header<'static>
[src]fn from(header: StrictTransportSecurity) -> Header<'static>
[src]
fn from(header: StrictTransportSecurity) -> Header<'static>
[src]Performs the conversion.
impl From<TransferEncoding> for Header<'static>
[src]
impl From<TransferEncoding> for Header<'static>
[src]fn from(header: TransferEncoding) -> Header<'static>
[src]
fn from(header: TransferEncoding) -> Header<'static>
[src]Performs the conversion.
impl Into<Header<'static>> for ContentType
[src]
impl Into<Header<'static>> for ContentType
[src]Creates a new Header
with name Content-Type
and the value set to the
HTTP rendering of this Content-Type.
impl Into<Header<'static>> for Accept
[src]
impl Into<Header<'static>> for Accept
[src]Creates a new Header
with name Accept
and the value set to the HTTP
rendering of this Accept
header.
impl<'h> Eq for Header<'h>
[src]
impl<'h> StructuralEq for Header<'h>
[src]
impl<'h> StructuralPartialEq for Header<'h>
[src]
Auto Trait Implementations
impl<'h> RefUnwindSafe for Header<'h>
impl<'h> Send for Header<'h>
impl<'h> Sync for Header<'h>
impl<'h> Unpin for Header<'h>
impl<'h> UnwindSafe for Header<'h>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T> IntoCollection<T> for T
[src]
impl<T> IntoCollection<T> for T
[src]impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more