http_types

Struct Trailers

Source
pub struct Trailers { /* private fields */ }
Expand description

A collection of trailing HTTP headers.

Implementations§

Source§

impl Trailers

Source

pub fn new() -> Self

Create a new instance of Trailers.

Source

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

Insert a header into the headers.

§Examples
use http_types::Trailers;

let mut trailers = Trailers::new();
trailers.insert("Content-Type", "text/plain");
Source

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.

§Examples
use http_types::Trailers;

let mut trailers = Trailers::new();
trailers.append("Content-Type", "text/plain");
Source

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

Get a reference to a header.

Source

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

Get a mutable reference to a header.

Source

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

Remove a header.

Source

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

An iterator visiting all header pairs in arbitrary order.

Source

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

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

Source

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

An iterator visiting all header names in arbitrary order.

Source

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

An iterator visiting all header values in arbitrary order.

Methods from Deref<Target = Headers>§

Source

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

Source

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.

Source

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

Get a reference to a header.

Source

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

Get a mutable reference to a header.

Source

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

Remove a header.

Source

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

An iterator visiting all header pairs in arbitrary order.

Source

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

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

Source

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

An iterator visiting all header names in arbitrary order.

Source

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

An iterator visiting all header values in arbitrary order.

Trait Implementations§

Source§

impl Clone for Trailers

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Trailers

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for Trailers

Source§

type Target = Headers

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for Trailers

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl Index<&str> for Trailers

Source§

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 Trailers.

Source§

type Output = HeaderValues

The returned type after indexing.
Source§

impl Index<HeaderName> for Trailers

Source§

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 Trailers.

Source§

type Output = HeaderValues

The returned type after indexing.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T