pub struct Trailers { /* private fields */ }
Expand description
A collection of trailing HTTP headers.
Implementations§
Source§impl Trailers
impl Trailers
Sourcepub fn insert(
&mut self,
name: impl Into<HeaderName>,
values: impl ToHeaderValues,
) -> Option<HeaderValues>
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");
Sourcepub fn append(
&mut self,
name: impl Into<HeaderName>,
values: impl ToHeaderValues,
)
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");
Sourcepub fn get(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>
pub fn get(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>
Get a reference to a header.
Sourcepub fn get_mut(
&mut self,
name: impl Into<HeaderName>,
) -> Option<&mut HeaderValues>
pub fn get_mut( &mut self, name: impl Into<HeaderName>, ) -> Option<&mut HeaderValues>
Get a mutable reference to a header.
Sourcepub fn remove(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues>
pub fn remove(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues>
Remove a header.
Methods from Deref<Target = Headers>§
Sourcepub fn insert(
&mut self,
name: impl Into<HeaderName>,
values: impl ToHeaderValues,
) -> Option<HeaderValues>
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
Sourcepub fn append(
&mut self,
name: impl Into<HeaderName>,
values: impl ToHeaderValues,
)
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.
Sourcepub fn get(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>
pub fn get(&self, name: impl Into<HeaderName>) -> Option<&HeaderValues>
Get a reference to a header.
Sourcepub fn get_mut(
&mut self,
name: impl Into<HeaderName>,
) -> Option<&mut HeaderValues>
pub fn get_mut( &mut self, name: impl Into<HeaderName>, ) -> Option<&mut HeaderValues>
Get a mutable reference to a header.
Sourcepub fn remove(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues>
pub fn remove(&mut self, name: impl Into<HeaderName>) -> Option<HeaderValues>
Remove a header.
Trait Implementations§
Source§impl Index<&str> for Trailers
impl Index<&str> for Trailers
Source§fn index(&self, name: &str) -> &HeaderValues
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
type Output = HeaderValues
Source§impl Index<HeaderName> for Trailers
impl Index<HeaderName> for Trailers
Source§fn index(&self, name: HeaderName) -> &HeaderValues
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
.