[−][src]Struct rocket::http::Header
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]
pub fn new<'a, 'b, N, V>(name: N, value: V) -> Header<'h> where
'a: 'h,
'b: 'h,
N: Into<Cow<'a, str>>,
V: Into<Cow<'b, str>>,
[src]
'a: 'h,
'b: 'h,
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]
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]
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<'h> Clone for Header<'h>
[src]
impl<'h> Debug for Header<'h>
[src]
impl<'h> Display for Header<'h>
[src]
impl<'h> Eq for Header<'h>
[src]
impl<'a, 'c> From<&'a Cookie<'c>> for Header<'static>
[src]
impl From<Accept> for Header<'static>
[src]
impl From<AcceptCharset> for Header<'static>
[src]
fn from(header: AcceptCharset) -> Header<'static>
[src]
impl From<AcceptEncoding> for Header<'static>
[src]
fn from(header: AcceptEncoding) -> Header<'static>
[src]
impl From<AcceptLanguage> for Header<'static>
[src]
fn from(header: AcceptLanguage) -> Header<'static>
[src]
impl From<AcceptRanges> for Header<'static>
[src]
fn from(header: AcceptRanges) -> Header<'static>
[src]
impl From<AccessControlAllowCredentials> for Header<'static>
[src]
fn from(header: AccessControlAllowCredentials) -> Header<'static>
[src]
impl From<AccessControlAllowHeaders> for Header<'static>
[src]
fn from(header: AccessControlAllowHeaders) -> Header<'static>
[src]
impl From<AccessControlAllowMethods> for Header<'static>
[src]
fn from(header: AccessControlAllowMethods) -> Header<'static>
[src]
impl From<AccessControlAllowOrigin> for Header<'static>
[src]
fn from(header: AccessControlAllowOrigin) -> Header<'static>
[src]
impl From<AccessControlExposeHeaders> for Header<'static>
[src]
fn from(header: AccessControlExposeHeaders) -> Header<'static>
[src]
impl From<AccessControlMaxAge> for Header<'static>
[src]
fn from(header: AccessControlMaxAge) -> Header<'static>
[src]
impl From<AccessControlRequestHeaders> for Header<'static>
[src]
fn from(header: AccessControlRequestHeaders) -> Header<'static>
[src]
impl From<AccessControlRequestMethod> for Header<'static>
[src]
fn from(header: AccessControlRequestMethod) -> Header<'static>
[src]
impl From<Allow> for Header<'static>
[src]
impl From<CacheControl> for Header<'static>
[src]
fn from(header: CacheControl) -> Header<'static>
[src]
impl From<Connection> for Header<'static>
[src]
fn from(header: Connection) -> Header<'static>
[src]
impl From<ContentDisposition> for Header<'static>
[src]
fn from(header: ContentDisposition) -> Header<'static>
[src]
impl From<ContentEncoding> for Header<'static>
[src]
fn from(header: ContentEncoding) -> Header<'static>
[src]
impl From<ContentLanguage> for Header<'static>
[src]
fn from(header: ContentLanguage) -> Header<'static>
[src]
impl From<ContentLength> for Header<'static>
[src]
fn from(header: ContentLength) -> Header<'static>
[src]
impl From<ContentRange> for Header<'static>
[src]
fn from(header: ContentRange) -> Header<'static>
[src]
impl<'c> From<Cookie<'c>> for Header<'static>
[src]
impl From<Date> for Header<'static>
[src]
impl From<ETag> for Header<'static>
[src]
impl From<Expect> for Header<'static>
[src]
impl From<Expires> for Header<'static>
[src]
impl From<Host> for Header<'static>
[src]
impl From<IfMatch> for Header<'static>
[src]
impl From<IfModifiedSince> for Header<'static>
[src]
fn from(header: IfModifiedSince) -> Header<'static>
[src]
impl From<IfNoneMatch> for Header<'static>
[src]
fn from(header: IfNoneMatch) -> Header<'static>
[src]
impl From<IfRange> for Header<'static>
[src]
impl From<IfUnmodifiedSince> for Header<'static>
[src]
fn from(header: IfUnmodifiedSince) -> Header<'static>
[src]
impl From<LastModified> for Header<'static>
[src]
fn from(header: LastModified) -> Header<'static>
[src]
impl From<Location> for Header<'static>
[src]
impl From<Origin> for Header<'static>
[src]
impl From<Pragma> for Header<'static>
[src]
impl From<Prefer> for Header<'static>
[src]
impl From<PreferenceApplied> for Header<'static>
[src]
fn from(header: PreferenceApplied) -> Header<'static>
[src]
impl From<Range> for Header<'static>
[src]
impl From<Referer> for Header<'static>
[src]
impl From<ReferrerPolicy> for Header<'static>
[src]
fn from(header: ReferrerPolicy) -> Header<'static>
[src]
impl From<StrictTransportSecurity> for Header<'static>
[src]
fn from(header: StrictTransportSecurity) -> Header<'static>
[src]
impl From<TransferEncoding> for Header<'static>
[src]
fn from(header: TransferEncoding) -> Header<'static>
[src]
impl From<Upgrade> for Header<'static>
[src]
impl From<UserAgent> for Header<'static>
[src]
impl From<Vary> for Header<'static>
[src]
impl<'h> Hash for Header<'h>
[src]
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
[src]
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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]
Creates a new Header
with name Accept
and the value set to the HTTP
rendering of this Accept
header.
impl<'h> PartialEq<Header<'h>> 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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, I> AsResult<T, I> for T where
I: Input,
[src]
I: Input,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoCollection<T> for T
[src]
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
[src]
A: Array<Item = T>,
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
[src]
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
[src]
T: Any,