pub struct HeaderValues(/* private fields */);
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§

source§

impl HeaderValues

source

pub fn new() -> HeaderValues

Creates a new empty HeaderValues.

source

pub fn from_inner(inner: HeaderMap) -> HeaderValues

Creates a new HeaderValues from it’s inner type.

source

pub fn insert<K, V>(&mut self, key: K, val: V) -> Option<HeaderValue>where K: IntoHeaderName, V: TryInto<HeaderValue>, <V as TryInto<HeaderValue>>::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.

source

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.

source

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.

source

pub fn serialize_value<K, V>( &mut self, key: K, val: &V ) -> Result<Option<HeaderValue>, Error>where K: IntoHeaderName, V: Serialize + ?Sized,

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.

source

pub fn get<K>(&self, key: K) -> Option<&HeaderValue>where K: AsHeaderName,

Returns the value if it exists.

source

pub fn get_mut<K>(&mut self, key: K) -> Option<&mut HeaderValue>where K: AsHeaderName,

Returns the value mutably if it exists.

source

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.

source

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.

source

pub fn deserialize_value<K, D>(&self, key: K) -> Option<D>where K: AsHeaderName, D: DeserializeOwned,

Deserializes a given value. Returning None if the value does not exist or is not valid json.

source

pub fn into_inner(self) -> HeaderMap

Returns the inner HeaderMap.

Trait Implementations§

source§

impl Clone for HeaderValues

source§

fn clone(&self) -> HeaderValues

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 HeaderValues

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

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

§

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