pub struct HeaderValue { /* private fields */ }
Expand description
A header value.
Since header values do not have to be valid utf8, this allows for both utf8 strings and bags of bytes.
Implementations§
Source§impl HeaderValue
impl HeaderValue
Sourcepub fn string(str: String) -> HeaderValue
pub fn string(str: String) -> HeaderValue
Construct a HeaderValue
from a string
Sourcepub fn bytes(bytes: Vec<u8>) -> HeaderValue
pub fn bytes(bytes: Vec<u8>) -> HeaderValue
Construct a HeaderValue
from a bag of bytes
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Get the HeaderValue
as a utf8 encoded string
Returns None
if the value is a non utf8 encoded header value
Sourcepub fn into_utf8_lossy(self) -> String
pub fn into_utf8_lossy(self) -> String
Turn the HeaderValue
into a String (in a lossy way if the HeaderValue
is a bag of bytes)
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Turn the HeaderValue
into bytes
Trait Implementations§
Source§impl AsRef<[u8]> for HeaderValue
impl AsRef<[u8]> for HeaderValue
Source§impl Clone for HeaderValue
impl Clone for HeaderValue
Source§fn clone(&self) -> HeaderValue
fn clone(&self) -> HeaderValue
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for HeaderValue
impl Debug for HeaderValue
Source§impl PartialEq for HeaderValue
impl PartialEq for HeaderValue
impl Eq for HeaderValue
impl StructuralPartialEq for HeaderValue
Auto Trait Implementations§
impl Freeze for HeaderValue
impl RefUnwindSafe for HeaderValue
impl Send for HeaderValue
impl Sync for HeaderValue
impl Unpin for HeaderValue
impl UnwindSafe for HeaderValue
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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)