Struct rocket::http::Header
[−]
[src]
pub struct Header<'h> { pub name: Cow<'h, str>, pub value: Cow<'h, str>, }
Simple representation of an HTTP header.
Fields
name: Cow<'h, str>
The name of the header.
value: Cow<'h, str>
The value of the header.
Methods
impl<'h> Header<'h>
[src]
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");
Trait Implementations
impl<'h> Debug for Header<'h>
[src]
impl<'h> Clone for 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
Performs copy-assignment from source
. Read more
impl<'h> Hash for Header<'h>
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl<'h> PartialEq for Header<'h>
[src]
fn eq(&self, __arg_0: &Header<'h>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Header<'h>) -> bool
This method tests for !=
.