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
.
source§type Output = HeaderValues
type Output = HeaderValues
Auto Trait Implementations§
impl Freeze for Trailers
impl RefUnwindSafe for Trailers
impl Send for Trailers
impl Sync for Trailers
impl Unpin for Trailers
impl UnwindSafe for Trailers
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)