pub trait HeaderMapExtT {
Show 18 methods
// Required methods
fn contains_headerkey(&self, key: impl HeaderKeyT) -> bool;
fn get_exact<K>(&self, key: K) -> Option<&HeaderValue>
where K: AsHeaderName;
fn insert_exact(&mut self, key: HeaderName, value: HeaderValue) -> &mut Self;
// Provided methods
fn get_ascii<K>(&self, key: K) -> Option<&str>
where K: HeaderAsciiKeyT { ... }
fn get_bin<K>(&self, key: K) -> Result<Option<Vec<u8>>>
where K: HeaderBinaryKeyT { ... }
fn get_bin_to_buffer<K>(&self, key: K, buffer: &mut Vec<u8>) -> Result<()>
where K: HeaderBinaryKeyT { ... }
fn get_bin_struct<K, T>(&self, key: K) -> Result<Option<T>>
where K: HeaderBinaryKeyT,
T: Message + Default { ... }
fn get_bin_struct_or_default<K, T>(&self, key: K) -> Result<T>
where K: HeaderBinaryKeyT,
T: Message + Default { ... }
fn insert_ascii<K, V>(
&mut self,
key: K,
value: V,
) -> Result<&mut Self, InvalidHeaderValue>
where K: HeaderAsciiKeyT,
V: TryInto<HeaderValue, Error = InvalidHeaderValue> { ... }
fn insert_ascii_any<K, V>(
&mut self,
key: K,
value: V,
) -> Result<&mut Self, InvalidHeaderValue>
where K: HeaderAsciiKeyT,
V: StringExtT { ... }
fn insert_ascii_infallible<K, V>(&mut self, key: K, value: V) -> &mut Self
where K: HeaderAsciiKeyT,
V: TryInto<HeaderValue, Error = Infallible> { ... }
fn insert_ascii_static<K>(
&mut self,
key: K,
value: &'static str,
) -> &mut Self
where K: HeaderAsciiKeyT { ... }
fn insert_bin<K, V>(&mut self, key: K, value: V) -> &mut Self
where K: HeaderBinaryKeyT,
V: TryInto<HeaderValue, Error = InvalidHeaderValue> { ... }
fn insert_bin_any<K, V>(&mut self, key: K, value: V) -> &mut Self
where K: HeaderBinaryKeyT,
V: Base64EncoderT { ... }
fn insert_bin_byte<K, V>(&mut self, key: K, value: V) -> &mut Self
where K: HeaderBinaryKeyT,
V: AsRef<[u8]> { ... }
fn insert_bin_struct<K, V>(
&mut self,
key: K,
value: V,
) -> Result<&mut Self, EncodeError>
where K: HeaderBinaryKeyT,
V: Message + Default { ... }
fn insert_bin_static<K>(&mut self, key: K, value: &'static str) -> &mut Self
where K: HeaderBinaryKeyT { ... }
fn insert_default(&mut self, key: impl HeaderKeyT) -> &mut Self { ... }
}Expand description
Trait for extending http::HeaderMap’s methods.
If T implements this trait, &mut T will also implement this trait.
Required Methods§
Sourcefn contains_headerkey(&self, key: impl HeaderKeyT) -> bool
fn contains_headerkey(&self, key: impl HeaderKeyT) -> bool
Check if key exist, just a bridge to HeaderMap or any else
Sourcefn get_exact<K>(&self, key: K) -> Option<&HeaderValue>where
K: AsHeaderName,
fn get_exact<K>(&self, key: K) -> Option<&HeaderValue>where
K: AsHeaderName,
Get value with exact type, just a bridge to HeaderMap or any else
Accept any key type that can be converted to HeaderName, see
AsHeaderName. It can be HeaderName, &’a HeaderName, &’a
str or String.
Sourcefn insert_exact(&mut self, key: HeaderName, value: HeaderValue) -> &mut Self
fn insert_exact(&mut self, key: HeaderName, value: HeaderValue) -> &mut Self
Insert value with exact type, just a bridge to HeaderMap or any else
Provided Methods§
Sourcefn get_ascii<K>(&self, key: K) -> Option<&str>where
K: HeaderAsciiKeyT,
fn get_ascii<K>(&self, key: K) -> Option<&str>where
K: HeaderAsciiKeyT,
Returns a reference to the value associated with the key.
For gRPC Metadata, please use get_bin
instead.
Notice: if value contains invalid header value characters(non-ascii), it
will be ignored and return None.
Sourcefn get_bin<K>(&self, key: K) -> Result<Option<Vec<u8>>>where
K: HeaderBinaryKeyT,
fn get_bin<K>(&self, key: K) -> Result<Option<Vec<u8>>>where
K: HeaderBinaryKeyT,
Returns the decoded base64-encoded value associated with the key, if the key-value pair exists.
§Errors
- Invalid Base64 string.
Sourcefn get_bin_to_buffer<K>(&self, key: K, buffer: &mut Vec<u8>) -> Result<()>where
K: HeaderBinaryKeyT,
fn get_bin_to_buffer<K>(&self, key: K, buffer: &mut Vec<u8>) -> Result<()>where
K: HeaderBinaryKeyT,
Extend the given buffer with the decoded base64-encoded value associated with the key, if the key-value pair exists.
§Errors
- Invalid Base64 string.
Sourcefn get_bin_struct<K, T>(&self, key: K) -> Result<Option<T>>
fn get_bin_struct<K, T>(&self, key: K) -> Result<Option<T>>
Returns the struct decoded from the gRPC metadata binary value, if the key-value pair exists.
§Errors
prost::DecodeError.- Invalid Base64 string.
Sourcefn get_bin_struct_or_default<K, T>(&self, key: K) -> Result<T>
fn get_bin_struct_or_default<K, T>(&self, key: K) -> Result<T>
Returns the struct decoded from the gRPC metadata binary value, or a default one if the key-value pair does not exist.
§Errors
prost::DecodeError.- Invalid Base64 string.
Sourcefn insert_ascii<K, V>(
&mut self,
key: K,
value: V,
) -> Result<&mut Self, InvalidHeaderValue>
fn insert_ascii<K, V>( &mut self, key: K, value: V, ) -> Result<&mut Self, InvalidHeaderValue>
Inserts a key-value pair into the inner HeaderMap.
For gRPC Metadata, please use
insert_bin instead.
§Errors
InvalidHeaderValueif the value contains invalid header value characters.
Sourcefn insert_ascii_any<K, V>(
&mut self,
key: K,
value: V,
) -> Result<&mut Self, InvalidHeaderValue>where
K: HeaderAsciiKeyT,
V: StringExtT,
fn insert_ascii_any<K, V>(
&mut self,
key: K,
value: V,
) -> Result<&mut Self, InvalidHeaderValue>where
K: HeaderAsciiKeyT,
V: StringExtT,
Inserts a key-value pair into the inner HeaderMap.
value can be any type that implements StringExtT.
For gRPC Metadata, please use
insert_bin instead.
§Errors
InvalidHeaderValueif the value contains invalid header value characters.
Sourcefn insert_ascii_infallible<K, V>(&mut self, key: K, value: V) -> &mut Self
fn insert_ascii_infallible<K, V>(&mut self, key: K, value: V) -> &mut Self
Inserts a key-value pair into the inner HeaderMap.
For gRPC Metadata, please use
insert_bin instead.
Sourcefn insert_ascii_static<K>(&mut self, key: K, value: &'static str) -> &mut Selfwhere
K: HeaderAsciiKeyT,
fn insert_ascii_static<K>(&mut self, key: K, value: &'static str) -> &mut Selfwhere
K: HeaderAsciiKeyT,
Inserts a key-value pair into the inner HeaderMap.
For gRPC Metadata, please use
insert_bin instead.
Sourcefn insert_bin<K, V>(&mut self, key: K, value: V) -> &mut Self
fn insert_bin<K, V>(&mut self, key: K, value: V) -> &mut Self
Sourcefn insert_bin_any<K, V>(&mut self, key: K, value: V) -> &mut Selfwhere
K: HeaderBinaryKeyT,
V: Base64EncoderT,
fn insert_bin_any<K, V>(&mut self, key: K, value: V) -> &mut Selfwhere
K: HeaderBinaryKeyT,
V: Base64EncoderT,
Inserts a key-value pair into the inner HeaderMap.
value can be any type that implement Base64EncoderT.
See [b64_padding::STANDARD_NO_PAD::encode](data), etc for more
details.
§Panics
Panic if the value is not a valid header value (it’s not possible unless upstream bug).
Sourcefn insert_bin_byte<K, V>(&mut self, key: K, value: V) -> &mut Self
fn insert_bin_byte<K, V>(&mut self, key: K, value: V) -> &mut Self
Sourcefn insert_bin_struct<K, V>(
&mut self,
key: K,
value: V,
) -> Result<&mut Self, EncodeError>
fn insert_bin_struct<K, V>( &mut self, key: K, value: V, ) -> Result<&mut Self, EncodeError>
Sourcefn insert_bin_static<K>(&mut self, key: K, value: &'static str) -> &mut Selfwhere
K: HeaderBinaryKeyT,
fn insert_bin_static<K>(&mut self, key: K, value: &'static str) -> &mut Selfwhere
K: HeaderBinaryKeyT,
Inserts a key-value pair into the inner HeaderMap.
Caller must ensure the value is valid base64 string.
Sourcefn insert_default(&mut self, key: impl HeaderKeyT) -> &mut Self
fn insert_default(&mut self, key: impl HeaderKeyT) -> &mut Self
Insert default value of T that implement HeaderKeyT
It’s a no-op if there’s no default value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.