Struct fire_http_representation::header::values::HeaderValues
source · pub struct HeaderValues(_);
Expand description
Contains all http header values.
This is really similar to http::header::HeaderMap
except
that is uses IntoHeaderValue for inserting. And it does not allow
multiples values for a given key.
Implementations
sourceimpl HeaderValues
impl HeaderValues
sourcepub fn from_inner(inner: HeaderMap<HeaderValue>) -> Self
pub fn from_inner(inner: HeaderMap<HeaderValue>) -> Self
Creates a new HeaderValues
from it’s inner type.
sourcepub fn insert<K, V>(&mut self, key: K, val: V) -> Option<HeaderValue>where
K: IntoHeaderName,
V: TryInto<HeaderValue>,
V::Error: Debug,
pub fn insert<K, V>(&mut self, key: K, val: V) -> Option<HeaderValue>where
K: IntoHeaderName,
V: TryInto<HeaderValue>,
V::Error: Debug,
Insert a new key and value into the header.
If a value to this key is already present that value is dropped.
Panics
If the value is not a valid HeaderValue.
sourcepub fn try_insert<K, V>(
&mut self,
key: K,
val: V
) -> Result<Option<HeaderValue>, InvalidHeaderValue>where
K: IntoHeaderName,
V: TryInto<HeaderValue, Error = InvalidHeaderValue>,
pub fn try_insert<K, V>(
&mut self,
key: K,
val: V
) -> Result<Option<HeaderValue>, InvalidHeaderValue>where
K: IntoHeaderName,
V: TryInto<HeaderValue, Error = InvalidHeaderValue>,
Insert a new key and value into the header. Returning None if the value is not valid.
If a value to this key is already present that value is dropped.
sourcepub fn encode_value<K, V>(&mut self, key: K, val: V) -> Option<HeaderValue>where
K: IntoHeaderName,
V: IntoEncodedHeaderValue,
pub fn encode_value<K, V>(&mut self, key: K, val: V) -> Option<HeaderValue>where
K: IntoHeaderName,
V: IntoEncodedHeaderValue,
Insert a new key and value into the header. Percent encoding the value if necessary.
sourcepub fn serialize_value<K, V: ?Sized>(
&mut self,
key: K,
val: &V
) -> Result<Option<HeaderValue>, JsonError>where
K: IntoHeaderName,
V: Serialize,
Available on crate feature json
only.
pub fn serialize_value<K, V: ?Sized>(
&mut self,
key: K,
val: &V
) -> Result<Option<HeaderValue>, JsonError>where
K: IntoHeaderName,
V: Serialize,
json
only.Insert a new key and a serializeable value. The value will be serialized as json and percent encoded.
Returns None
if the value could not be serialized or inserted.
sourcepub fn get<K>(&self, key: K) -> Option<&HeaderValue>where
K: AsHeaderName,
pub fn get<K>(&self, key: K) -> Option<&HeaderValue>where
K: AsHeaderName,
Returns the value if it exists.
sourcepub fn get_mut<K>(&mut self, key: K) -> Option<&mut HeaderValue>where
K: AsHeaderName,
pub fn get_mut<K>(&mut self, key: K) -> Option<&mut HeaderValue>where
K: AsHeaderName,
Returns the value mutably if it exists.
sourcepub fn get_str<K>(&self, key: K) -> Option<&str>where
K: AsHeaderName,
pub fn get_str<K>(&self, key: K) -> Option<&str>where
K: AsHeaderName,
Returns the value as a string if it exists and is valid.
sourcepub fn decode_value<K>(&self, key: K) -> Option<Cow<'_, str>>where
K: AsHeaderName,
pub fn decode_value<K>(&self, key: K) -> Option<Cow<'_, str>>where
K: AsHeaderName,
Returns the value percent decoded as a string if it exists and is valid.
sourcepub fn deserialize_value<K, D>(&self, key: K) -> Option<D>where
K: AsHeaderName,
D: DeserializeOwned,
Available on crate feature json
only.
pub fn deserialize_value<K, D>(&self, key: K) -> Option<D>where
K: AsHeaderName,
D: DeserializeOwned,
json
only.Deserializes a given value. Returning None
if the value
does not exist or is not valid json.
sourcepub fn into_inner(self) -> HeaderMap<HeaderValue>
pub fn into_inner(self) -> HeaderMap<HeaderValue>
Returns the inner HeaderMap
.
Trait Implementations
sourceimpl Clone for HeaderValues
impl Clone for HeaderValues
sourcefn clone(&self) -> HeaderValues
fn clone(&self) -> HeaderValues
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more