Struct sig_proxy::middleware::proxy::prelude::headers::Headers[]

pub struct Headers { /* fields omitted */ }
Expand description

A collection of HTTP Headers.

Headers are never manually constructed, but are part of Request, Response, and Trailers. Each of these types implements AsRef<Headers> and AsMut<Headers> so functions that want to modify headers can be generic over either of these traits.

Examples

use http_types::{Response, StatusCode};

let mut res = Response::new(StatusCode::Ok);
res.insert_header("hello", "foo0");
assert_eq!(res["hello"], "foo0");

Implementations

impl Headers

pub fn insert(
    &mut self,
    name: impl Into<HeaderName>,
    values: impl ToHeaderValues
) -> Option<HeaderValues>

Insert a header into the headers.

Not that this will replace all header values for a given header name. If you wish to add header values for a header name that already exists use Headers::append

pub fn append(
    &mut self,
    name: impl Into<HeaderName>,
    values: impl ToHeaderValues
)

Append a header to the headers.

Unlike insert this function will not override the contents of a header, but insert a header if there aren’t any. Or else append to the existing list of headers.

pub fn get(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>

Get a reference to a header.

pub fn get_mut(
    &mut self,
    name: impl Into<HeaderName>
) -> Option<&mut HeaderValues>

Get a mutable reference to a header.

pub fn remove(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues>

Remove a header.

pub fn iter(&self) -> Iter<'_>

Notable traits for Iter<'a>

impl<'a> Iterator for Iter<'a> type Item = (&'a HeaderName, &'a HeaderValues);

An iterator visiting all header pairs in arbitrary order.

pub fn iter_mut(&mut self) -> IterMut<'_>

Notable traits for IterMut<'a>

impl<'a> Iterator for IterMut<'a> type Item = (&'a HeaderName, &'a mut HeaderValues);

An iterator visiting all header pairs in arbitrary order, with mutable references to the values.

pub fn names(&self) -> Names<'_>

Notable traits for Names<'a>

impl<'a> Iterator for Names<'a> type Item = &'a HeaderName;

An iterator visiting all header names in arbitrary order.

pub fn values(&self) -> Values<'_>

Notable traits for Values<'a>

impl<'a> Iterator for Values<'a> type Item = &'a HeaderValue;

An iterator visiting all header values in arbitrary order.

Trait Implementations

impl AsMut<Headers> for Headers

pub fn as_mut(&mut self) -> &mut Headers

Performs the conversion.

impl AsRef<Headers> for Headers

pub fn as_ref(&self) -> &Headers

Performs the conversion.

impl Clone for Headers

pub fn clone(&self) -> Headers

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Headers

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

impl<'_> Index<&'_ str> for Headers

pub fn index(&self, name: &str) -> &HeaderValues

Returns a reference to the value corresponding to the supplied name.

Panics

Panics if the name is not present in Headers.

type Output = HeaderValues

The returned type after indexing.

impl Index<HeaderName> for Headers

pub fn index(&self, name: HeaderName) -> &HeaderValues

Returns a reference to the value corresponding to the supplied name.

Panics

Panics if the name is not present in Headers.

type Output = HeaderValues

The returned type after indexing.

impl IntoIterator for Headers

pub fn into_iter(self) -> <Headers as IntoIterator>::IntoIter

Returns a iterator of references over the remaining items.

type Item = (HeaderName, HeaderValues)

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

impl<'a> IntoIterator for &'a mut Headers

type Item = (&'a HeaderName, &'a mut HeaderValues)

The type of the elements being iterated over.

type IntoIter = IterMut<'a>

Which kind of iterator are we turning this into?

pub fn into_iter(self) -> <&'a mut Headers as IntoIterator>::IntoIter

Creates an iterator from a value. Read more

impl<'a> IntoIterator for &'a Headers

type Item = (&'a HeaderName, &'a HeaderValues)

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

pub fn into_iter(self) -> <&'a Headers as IntoIterator>::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations

impl RefUnwindSafe for Headers

impl Send for Headers

impl Sync for Headers

impl Unpin for Headers

impl UnwindSafe for Headers

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V