Struct HeaderMap

pub struct HeaderMap<T = HeaderValue> {
    mask: u16,
    indices: Box<[Pos]>,
    entries: Vec<Bucket<T>>,
    extra_values: Vec<ExtraValue<T>>,
    danger: Danger,
}
Expand description

A set of HTTP headers

HeaderMap is a multimap of HeaderName to values.

ยงExamples

Basic usage

let mut headers = HeaderMap::new();

headers.insert(HOST, "example.com".parse().unwrap());
headers.insert(CONTENT_LENGTH, "123".parse().unwrap());

assert!(headers.contains_key(HOST));
assert!(!headers.contains_key(LOCATION));

assert_eq!(headers[HOST], "example.com");

headers.remove(HOST);

assert!(!headers.contains_key(HOST));

Fieldsยง

ยงmask: u16ยงindices: Box<[Pos]>ยงentries: Vec<Bucket<T>>ยงextra_values: Vec<ExtraValue<T>>ยงdanger: Danger

Implementationsยง

ยง

impl HeaderMap

pub fn new() -> HeaderMap

Create an empty HeaderMap.

The map will be created without any capacity. This function will not allocate.

ยงExamples
let map = HeaderMap::new();

assert!(map.is_empty());
assert_eq!(0, map.capacity());
ยง

impl<T> HeaderMap<T>

pub fn with_capacity(capacity: usize) -> HeaderMap<T>

Create an empty HeaderMap with the specified capacity.

The returned map will allocate internal storage in order to hold about capacity elements without reallocating. However, this is a โ€œbest effortโ€ as there are usage patterns that could cause additional allocations before capacity headers are stored in the map.

More capacity than requested may be allocated.

ยงPanics

This method panics if capacity exceeds max HeaderMap capacity.

ยงExamples
let map: HeaderMap<u32> = HeaderMap::with_capacity(10);

assert!(map.is_empty());
assert_eq!(12, map.capacity());

pub fn try_with_capacity( capacity: usize, ) -> Result<HeaderMap<T>, MaxSizeReached>

Create an empty HeaderMap with the specified capacity.

The returned map will allocate internal storage in order to hold about capacity elements without reallocating. However, this is a โ€œbest effortโ€ as there are usage patterns that could cause additional allocations before capacity headers are stored in the map.

More capacity than requested may be allocated.

ยงErrors

This function may return an error if HeaderMap exceeds max capacity

ยงExamples
let map: HeaderMap<u32> = HeaderMap::try_with_capacity(10).unwrap();

assert!(map.is_empty());
assert_eq!(12, map.capacity());

pub fn len(&self) -> usize

Returns the number of headers stored in the map.

This number represents the total number of values stored in the map. This number can be greater than or equal to the number of keys stored given that a single key may have more than one associated value.

ยงExamples
let mut map = HeaderMap::new();

assert_eq!(0, map.len());

map.insert(ACCEPT, "text/plain".parse().unwrap());
map.insert(HOST, "localhost".parse().unwrap());

assert_eq!(2, map.len());

map.append(ACCEPT, "text/html".parse().unwrap());

assert_eq!(3, map.len());

pub fn keys_len(&self) -> usize

Returns the number of keys stored in the map.

This number will be less than or equal to len() as each key may have more than one associated value.

ยงExamples
let mut map = HeaderMap::new();

assert_eq!(0, map.keys_len());

map.insert(ACCEPT, "text/plain".parse().unwrap());
map.insert(HOST, "localhost".parse().unwrap());

assert_eq!(2, map.keys_len());

map.insert(ACCEPT, "text/html".parse().unwrap());

assert_eq!(2, map.keys_len());

pub fn is_empty(&self) -> bool

Returns true if the map contains no elements.

ยงExamples
let mut map = HeaderMap::new();

assert!(map.is_empty());

map.insert(HOST, "hello.world".parse().unwrap());

assert!(!map.is_empty());

pub fn clear(&mut self)

Clears the map, removing all key-value pairs. Keeps the allocated memory for reuse.

ยงExamples
let mut map = HeaderMap::new();
map.insert(HOST, "hello.world".parse().unwrap());

map.clear();
assert!(map.is_empty());
assert!(map.capacity() > 0);

pub fn capacity(&self) -> usize

Returns the number of headers the map can hold without reallocating.

This number is an approximation as certain usage patterns could cause additional allocations before the returned capacity is filled.

ยงExamples
let mut map = HeaderMap::new();

assert_eq!(0, map.capacity());

map.insert(HOST, "hello.world".parse().unwrap());
assert_eq!(6, map.capacity());

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more headers to be inserted into the HeaderMap.

The header map may reserve more space to avoid frequent reallocations. Like with with_capacity, this will be a โ€œbest effortโ€ to avoid allocations until additional more headers are inserted. Certain usage patterns could cause additional allocations before the number is reached.

ยงPanics

Panics if the new allocation size overflows HeaderMap MAX_SIZE.

ยงExamples
let mut map = HeaderMap::new();
map.reserve(10);

pub fn try_reserve(&mut self, additional: usize) -> Result<(), MaxSizeReached>

Reserves capacity for at least additional more headers to be inserted into the HeaderMap.

The header map may reserve more space to avoid frequent reallocations. Like with with_capacity, this will be a โ€œbest effortโ€ to avoid allocations until additional more headers are inserted. Certain usage patterns could cause additional allocations before the number is reached.

ยงErrors

This method differs from reserve by returning an error instead of panicking if the value is too large.

ยงExamples
let mut map = HeaderMap::new();
map.try_reserve(10).unwrap();

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

Returns a reference to the value associated with the key.

If there are multiple values associated with the key, then the first one is returned. Use get_all to get all values associated with a given key. Returns None if there are no values associated with the key.

ยงExamples
let mut map = HeaderMap::new();
assert!(map.get("host").is_none());

map.insert(HOST, "hello".parse().unwrap());
assert_eq!(map.get(HOST).unwrap(), &"hello");
assert_eq!(map.get("host").unwrap(), &"hello");

map.append(HOST, "world".parse().unwrap());
assert_eq!(map.get("host").unwrap(), &"hello");

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

Returns a mutable reference to the value associated with the key.

If there are multiple values associated with the key, then the first one is returned. Use entry to get all values associated with a given key. Returns None if there are no values associated with the key.

ยงExamples
let mut map = HeaderMap::default();
map.insert(HOST, "hello".to_string());
map.get_mut("host").unwrap().push_str("-world");

assert_eq!(map.get(HOST).unwrap(), &"hello-world");

pub fn get_all<K>(&self, key: K) -> GetAll<'_, T>
where K: AsHeaderName,

Returns a view of all values associated with a key.

The returned view does not incur any allocations and allows iterating the values associated with the key. See GetAll for more details. Returns None if there are no values associated with the key.

ยงExamples
let mut map = HeaderMap::new();

map.insert(HOST, "hello".parse().unwrap());
map.append(HOST, "goodbye".parse().unwrap());

let view = map.get_all("host");

let mut iter = view.iter();
assert_eq!(&"hello", iter.next().unwrap());
assert_eq!(&"goodbye", iter.next().unwrap());
assert!(iter.next().is_none());

pub fn contains_key<K>(&self, key: K) -> bool
where K: AsHeaderName,

Returns true if the map contains a value for the specified key.

ยงExamples
let mut map = HeaderMap::new();
assert!(!map.contains_key(HOST));

map.insert(HOST, "world".parse().unwrap());
assert!(map.contains_key("host"));

pub fn iter(&self) -> Iter<'_, T> โ“˜

An iterator visiting all key-value pairs.

The iteration order is arbitrary, but consistent across platforms for the same crate version. Each key will be yielded once per associated value. So, if a key has 3 associated values, it will be yielded 3 times.

ยงExamples
let mut map = HeaderMap::new();

map.insert(HOST, "hello".parse().unwrap());
map.append(HOST, "goodbye".parse().unwrap());
map.insert(CONTENT_LENGTH, "123".parse().unwrap());

for (key, value) in map.iter() {
    println!("{:?}: {:?}", key, value);
}

pub fn iter_mut(&mut self) -> IterMut<'_, T> โ“˜

An iterator visiting all key-value pairs, with mutable value references.

The iterator order is arbitrary, but consistent across platforms for the same crate version. Each key will be yielded once per associated value, so if a key has 3 associated values, it will be yielded 3 times.

ยงExamples
let mut map = HeaderMap::default();

map.insert(HOST, "hello".to_string());
map.append(HOST, "goodbye".to_string());
map.insert(CONTENT_LENGTH, "123".to_string());

for (key, value) in map.iter_mut() {
    value.push_str("-boop");
}

pub fn keys(&self) -> Keys<'_, T> โ“˜

An iterator visiting all keys.

The iteration order is arbitrary, but consistent across platforms for the same crate version. Each key will be yielded only once even if it has multiple associated values.

ยงExamples
let mut map = HeaderMap::new();

map.insert(HOST, "hello".parse().unwrap());
map.append(HOST, "goodbye".parse().unwrap());
map.insert(CONTENT_LENGTH, "123".parse().unwrap());

for key in map.keys() {
    println!("{:?}", key);
}

pub fn values(&self) -> Values<'_, T> โ“˜

An iterator visiting all values.

The iteration order is arbitrary, but consistent across platforms for the same crate version.

ยงExamples
let mut map = HeaderMap::new();

map.insert(HOST, "hello".parse().unwrap());
map.append(HOST, "goodbye".parse().unwrap());
map.insert(CONTENT_LENGTH, "123".parse().unwrap());

for value in map.values() {
    println!("{:?}", value);
}

pub fn values_mut(&mut self) -> ValuesMut<'_, T> โ“˜

An iterator visiting all values mutably.

The iteration order is arbitrary, but consistent across platforms for the same crate version.

ยงExamples
let mut map = HeaderMap::default();

map.insert(HOST, "hello".to_string());
map.append(HOST, "goodbye".to_string());
map.insert(CONTENT_LENGTH, "123".to_string());

for value in map.values_mut() {
    value.push_str("-boop");
}

pub fn drain(&mut self) -> Drain<'_, T> โ“˜

Clears the map, returning all entries as an iterator.

The internal memory is kept for reuse.

For each yielded item that has None provided for the HeaderName, then the associated header name is the same as that of the previously yielded item. The first yielded item will have HeaderName set.

ยงExamples
let mut map = HeaderMap::new();

map.insert(HOST, "hello".parse().unwrap());
map.append(HOST, "goodbye".parse().unwrap());
map.insert(CONTENT_LENGTH, "123".parse().unwrap());

let mut drain = map.drain();


assert_eq!(drain.next(), Some((Some(HOST), "hello".parse().unwrap())));
assert_eq!(drain.next(), Some((None, "goodbye".parse().unwrap())));

assert_eq!(drain.next(), Some((Some(CONTENT_LENGTH), "123".parse().unwrap())));

assert_eq!(drain.next(), None);

pub fn entry<K>(&mut self, key: K) -> Entry<'_, T>
where K: IntoHeaderName,

Gets the given keyโ€™s corresponding entry in the map for in-place manipulation.

ยงPanics

This method panics if capacity exceeds max HeaderMap capacity

ยงExamples
let mut map: HeaderMap<u32> = HeaderMap::default();

let headers = &[
    "content-length",
    "x-hello",
    "Content-Length",
    "x-world",
];

for &header in headers {
    let counter = map.entry(header).or_insert(0);
    *counter += 1;
}

assert_eq!(map["content-length"], 2);
assert_eq!(map["x-hello"], 1);

pub fn try_entry<K>( &mut self, key: K, ) -> Result<Entry<'_, T>, InvalidHeaderName>
where K: AsHeaderName,

Gets the given keyโ€™s corresponding entry in the map for in-place manipulation.

ยงErrors

This method differs from entry by allowing types that may not be valid HeaderNames to passed as the key (such as String). If they do not parse as a valid HeaderName, this returns an InvalidHeaderName error.

If reserving space goes over the maximum, this will also return an error. However, to prevent breaking changes to the return type, the error will still say InvalidHeaderName, unlike other try_* methods which return a MaxSizeReached error.

pub fn insert<K>(&mut self, key: K, val: T) -> Option<T>
where K: IntoHeaderName,

Inserts a key-value pair into the map.

If the map did not previously have this key present, then None is returned.

If the map did have this key present, the new value is associated with the key and all previous values are removed. Note that only a single one of the previous values is returned. If there are multiple values that have been previously associated with the key, then the first one is returned. See insert_mult on OccupiedEntry for an API that returns all values.

The key is not updated, though; this matters for types that can be == without being identical.

ยงPanics

This method panics if capacity exceeds max HeaderMap capacity

ยงExamples
let mut map = HeaderMap::new();
assert!(map.insert(HOST, "world".parse().unwrap()).is_none());
assert!(!map.is_empty());

let mut prev = map.insert(HOST, "earth".parse().unwrap()).unwrap();
assert_eq!("world", prev);

pub fn try_insert<K>( &mut self, key: K, val: T, ) -> Result<Option<T>, MaxSizeReached>
where K: IntoHeaderName,

Inserts a key-value pair into the map.

If the map did not previously have this key present, then None is returned.

If the map did have this key present, the new value is associated with the key and all previous values are removed. Note that only a single one of the previous values is returned. If there are multiple values that have been previously associated with the key, then the first one is returned. See insert_mult on OccupiedEntry for an API that returns all values.

The key is not updated, though; this matters for types that can be == without being identical.

ยงErrors

This function may return an error if HeaderMap exceeds max capacity

ยงExamples
let mut map = HeaderMap::new();
assert!(map.try_insert(HOST, "world".parse().unwrap()).unwrap().is_none());
assert!(!map.is_empty());

let mut prev = map.try_insert(HOST, "earth".parse().unwrap()).unwrap().unwrap();
assert_eq!("world", prev);

pub fn append<K>(&mut self, key: K, value: T) -> bool
where K: IntoHeaderName,

Inserts a key-value pair into the map.

If the map did not previously have this key present, then false is returned.

If the map did have this key present, the new value is pushed to the end of the list of values currently associated with the key. The key is not updated, though; this matters for types that can be == without being identical.

ยงPanics

This method panics if capacity exceeds max HeaderMap capacity

ยงExamples
let mut map = HeaderMap::new();
assert!(map.insert(HOST, "world".parse().unwrap()).is_none());
assert!(!map.is_empty());

map.append(HOST, "earth".parse().unwrap());

let values = map.get_all("host");
let mut i = values.iter();
assert_eq!("world", *i.next().unwrap());
assert_eq!("earth", *i.next().unwrap());

pub fn try_append<K>( &mut self, key: K, value: T, ) -> Result<bool, MaxSizeReached>
where K: IntoHeaderName,

Inserts a key-value pair into the map.

If the map did not previously have this key present, then false is returned.

If the map did have this key present, the new value is pushed to the end of the list of values currently associated with the key. The key is not updated, though; this matters for types that can be == without being identical.

ยงErrors

This function may return an error if HeaderMap exceeds max capacity

ยงExamples
let mut map = HeaderMap::new();
assert!(map.try_insert(HOST, "world".parse().unwrap()).unwrap().is_none());
assert!(!map.is_empty());

map.try_append(HOST, "earth".parse().unwrap()).unwrap();

let values = map.get_all("host");
let mut i = values.iter();
assert_eq!("world", *i.next().unwrap());
assert_eq!("earth", *i.next().unwrap());

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

Removes a key from the map, returning the value associated with the key.

Returns None if the map does not contain the key. If there are multiple values associated with the key, then the first one is returned. See remove_entry_mult on OccupiedEntry for an API that yields all values.

ยงExamples
let mut map = HeaderMap::new();
map.insert(HOST, "hello.world".parse().unwrap());

let prev = map.remove(HOST).unwrap();
assert_eq!("hello.world", prev);

assert!(map.remove(HOST).is_none());

Trait Implementationsยง

ยง

impl<T> Clone for HeaderMap<T>
where T: Clone,

ยง

fn clone(&self) -> HeaderMap<T>

Returns a duplicate of the value. Read more
1.0.0 ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
ยง

impl<T> Debug for HeaderMap<T>
where T: Debug,

ยง

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

Formats the value using the given formatter. Read more
ยง

impl<T> Default for HeaderMap<T>

ยง

fn default() -> HeaderMap<T>

Returns the โ€œdefault valueโ€ for a type. Read more
ยง

impl<T> Extend<(HeaderName, T)> for HeaderMap<T>

ยง

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = (HeaderName, T)>,

Extends a collection with the contents of an iterator. Read more
Sourceยง

fn extend_one(&mut self, item: A)

๐Ÿ”ฌThis is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Sourceยง

fn extend_reserve(&mut self, additional: usize)

๐Ÿ”ฌThis is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
ยง

impl<T> Extend<(Option<HeaderName>, T)> for HeaderMap<T>

ยง

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = (Option<HeaderName>, T)>,

Extend a HeaderMap with the contents of another HeaderMap.

This function expects the yielded items to follow the same structure as IntoIter.

ยงPanics

This panics if the first yielded item does not have a HeaderName.

ยงExamples
let mut map = HeaderMap::new();

map.insert(ACCEPT, "text/plain".parse().unwrap());
map.insert(HOST, "hello.world".parse().unwrap());

let mut extra = HeaderMap::new();

extra.insert(HOST, "foo.bar".parse().unwrap());
extra.insert(COOKIE, "hello".parse().unwrap());
extra.append(COOKIE, "world".parse().unwrap());

map.extend(extra);

assert_eq!(map["host"], "foo.bar");
assert_eq!(map["accept"], "text/plain");
assert_eq!(map["cookie"], "hello");

let v = map.get_all("host");
assert_eq!(1, v.iter().count());

let v = map.get_all("cookie");
assert_eq!(2, v.iter().count());
Sourceยง

fn extend_one(&mut self, item: A)

๐Ÿ”ฌThis is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Sourceยง

fn extend_reserve(&mut self, additional: usize)

๐Ÿ”ฌThis is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
ยง

impl<T> FromIterator<(HeaderName, T)> for HeaderMap<T>

ยง

fn from_iter<I>(iter: I) -> HeaderMap<T>
where I: IntoIterator<Item = (HeaderName, T)>,

Creates a value from an iterator. Read more
ยง

impl<S> FromRequestParts<S> for HeaderMap
where S: Send + Sync,

Clone the headers from the request.

Prefer using TypedHeader to extract only the headers you need.

ยง

type Rejection = Infallible

If the extractor fails itโ€™ll use this โ€œrejectionโ€ type. A rejection is a kind of error that can be converted into a response.
ยง

async fn from_request_parts( parts: &mut Parts, _: &S, ) -> Result<HeaderMap, <HeaderMap as FromRequestParts<S>>::Rejection>

Perform the extraction.
ยง

impl<K, T> Index<K> for HeaderMap<T>
where K: AsHeaderName,

ยง

fn index(&self, index: K) -> &T

ยงPanics

Using the index operator will cause a panic if the header youโ€™re querying isnโ€™t set.

ยง

type Output = T

The returned type after indexing.
ยง

impl<'a, T> IntoIterator for &'a HeaderMap<T>

ยง

type Item = (&'a HeaderName, &'a T)

The type of the elements being iterated over.
ยง

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
ยง

fn into_iter(self) -> Iter<'a, T> โ“˜

Creates an iterator from a value. Read more
ยง

impl<'a, T> IntoIterator for &'a mut HeaderMap<T>

ยง

type Item = (&'a HeaderName, &'a mut T)

The type of the elements being iterated over.
ยง

type IntoIter = IterMut<'a, T>

Which kind of iterator are we turning this into?
ยง

fn into_iter(self) -> IterMut<'a, T> โ“˜

Creates an iterator from a value. Read more
ยง

impl<T> IntoIterator for HeaderMap<T>

ยง

fn into_iter(self) -> IntoIter<T> โ“˜

Creates a consuming iterator, that is, one that moves keys and values out of the map in arbitrary order. The map cannot be used after calling this.

For each yielded item that has None provided for the HeaderName, then the associated header name is the same as that of the previously yielded item. The first yielded item will have HeaderName set.

ยงExamples

Basic usage.

let mut map = HeaderMap::new();
map.insert(header::CONTENT_LENGTH, "123".parse().unwrap());
map.insert(header::CONTENT_TYPE, "json".parse().unwrap());

let mut iter = map.into_iter();
assert_eq!(iter.next(), Some((Some(header::CONTENT_LENGTH), "123".parse().unwrap())));
assert_eq!(iter.next(), Some((Some(header::CONTENT_TYPE), "json".parse().unwrap())));
assert!(iter.next().is_none());

Multiple values per key.

let mut map = HeaderMap::new();

map.append(header::CONTENT_LENGTH, "123".parse().unwrap());
map.append(header::CONTENT_LENGTH, "456".parse().unwrap());

map.append(header::CONTENT_TYPE, "json".parse().unwrap());
map.append(header::CONTENT_TYPE, "html".parse().unwrap());
map.append(header::CONTENT_TYPE, "xml".parse().unwrap());

let mut iter = map.into_iter();

assert_eq!(iter.next(), Some((Some(header::CONTENT_LENGTH), "123".parse().unwrap())));
assert_eq!(iter.next(), Some((None, "456".parse().unwrap())));

assert_eq!(iter.next(), Some((Some(header::CONTENT_TYPE), "json".parse().unwrap())));
assert_eq!(iter.next(), Some((None, "html".parse().unwrap())));
assert_eq!(iter.next(), Some((None, "xml".parse().unwrap())));
assert!(iter.next().is_none());
ยง

type Item = (Option<HeaderName>, T)

The type of the elements being iterated over.
ยง

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
ยง

impl IntoResponse for HeaderMap

ยง

fn into_response(self) -> Response<Body>

Create a response.
ยง

impl IntoResponseParts for HeaderMap

ยง

type Error = Infallible

The type returned in the event of an error. Read more
ยง

fn into_response_parts( self, res: ResponseParts, ) -> Result<ResponseParts, <HeaderMap as IntoResponseParts>::Error>

Set parts of the response
ยง

impl<T> PartialEq for HeaderMap<T>
where T: PartialEq,

ยง

fn eq(&self, other: &HeaderMap<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
ยง

impl<'a, K, V, S, T> TryFrom<&'a HashMap<K, V, S>> for HeaderMap<T>

Try to convert a HashMap into a HeaderMap.

ยงExamples

use std::collections::HashMap;
use std::convert::TryInto;
use http::HeaderMap;

let mut map = HashMap::new();
map.insert("X-Custom-Header".to_string(), "my value".to_string());

let headers: HeaderMap = (&map).try_into().expect("valid headers");
assert_eq!(headers["X-Custom-Header"], "my value");
ยง

type Error = Error

The type returned in the event of a conversion error.
ยง

fn try_from( c: &'a HashMap<K, V, S>, ) -> Result<HeaderMap<T>, <HeaderMap<T> as TryFrom<&'a HashMap<K, V, S>>>::Error>

Performs the conversion.
ยง

impl TryParse for HeaderMap

ยง

fn try_parse(buf: &[u8]) -> Result<Option<(usize, HeaderMap)>, Error>

Return Ok(None) if incomplete, Err on syntax error.
ยง

impl<T> Eq for HeaderMap<T>
where T: Eq,

Auto Trait Implementationsยง

ยง

impl<T> Freeze for HeaderMap<T>

ยง

impl<T> RefUnwindSafe for HeaderMap<T>
where T: RefUnwindSafe,

ยง

impl<T> Send for HeaderMap<T>
where T: Send,

ยง

impl<T> Sync for HeaderMap<T>
where T: Sync,

ยง

impl<T> Unpin for HeaderMap<T>
where T: Unpin,

ยง

impl<T> UnwindSafe for HeaderMap<T>
where T: UnwindSafe,

Blanket Implementationsยง

Sourceยง

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Sourceยง

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
Sourceยง

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
Sourceยง

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

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
ยง

impl<T> ArchivePointee for T

ยง

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
ยง

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Sourceยง

impl<T, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Sourceยง

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Sourceยง

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Sourceยง

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
Sourceยง

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

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

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

Sourceยง

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

Mutably borrows from an owned value. Read more
Sourceยง

impl<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Sourceยง

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type thatโ€™s used in parameters when converting.
Sourceยง

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Sourceยง

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
ยง

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

ยง

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
ยง

impl<T> Downcast for T
where T: Any,

ยง

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
ยง

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
ยง

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Anyโ€™s vtable from &Traitโ€™s.
ยง

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Anyโ€™s vtable from &mut Traitโ€™s.
ยง

impl<T> DowncastSend for T
where T: Any + Send,

ยง

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
ยง

impl<T> DowncastSync for T
where T: Any + Send + Sync,

ยง

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
ยง

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
ยง

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

ยง

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T> FromAngle<T> for T

Sourceยง

fn from_angle(angle: T) -> T

Performs a conversion from angle.
ยง

impl<T> FromRef<T> for T
where T: Clone,

ยง

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
ยง

impl<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

ยง

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
ยง

impl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

ยง

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
ยง

impl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

ยง

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
ยง

impl<S, T> FromRequest<S, ViaParts> for T
where S: Send + Sync, T: FromRequestParts<S>,

ยง

type Rejection = <T as FromRequestParts<S>>::Rejection

If the extractor fails itโ€™ll use this โ€œrejectionโ€ type. A rejection is a kind of error that can be converted into a response.
ยง

fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>

Perform the extraction.
ยง

impl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

ยง

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
ยง

impl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

ยง

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
ยง

impl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

ยง

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Sourceยง

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Sourceยง

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
ยง

impl<T, S> Handler<IntoResponseHandler, S> for T
where T: IntoResponse + Clone + Send + Sync + 'static,

ยง

type Future = Ready<Response<Body>>

The type of future calling this handler returns.
ยง

fn call( self, _req: Request<Body>, _state: S, ) -> <T as Handler<IntoResponseHandler, S>>::Future

Call the handler with the given request.
ยง

fn layer<L>(self, layer: L) -> Layered<L, Self, T, S>
where L: Layer<HandlerService<Self, T, S>> + Clone, <L as Layer<HandlerService<Self, T, S>>>::Service: Service<Request<Body>>,

Apply a [tower::Layer] to the handler. Read more
ยง

fn with_state(self, state: S) -> HandlerService<Self, T, S>

Convert the handler into a [Service] by providing the state
ยง

impl<H, T> HandlerWithoutStateExt<T> for H
where H: Handler<T, ()>,

ยง

fn into_service(self) -> HandlerService<H, T, ()>

Convert the handler into a [Service] and no state.
ยง

fn into_make_service(self) -> IntoMakeService<HandlerService<H, T, ()>>

Convert the handler into a MakeService and no state. Read more
ยง

fn into_make_service_with_connect_info<C>( self, ) -> IntoMakeServiceWithConnectInfo<HandlerService<H, T, ()>, C>

Convert the handler into a MakeService which stores information about the incoming connection and has no state. Read more
ยง

impl<T> Instrument for T

ยง

fn instrument(self, span: Span) -> Instrumented<Self> โ“˜

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
ยง

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 T
where 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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Sourceยง

fn into_angle(self) -> U

Performs a conversion into T.
Sourceยง

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Sourceยง

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type thatโ€™s used in parameters when converting.
Sourceยง

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Sourceยง

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Sourceยง

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Sourceยง

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Sourceยง

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Sourceยง

impl<T> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self> โ“˜

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ“˜
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
ยง

impl<E, T, Encoding, Request> IntoReq<Patch<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

ยง

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
ยง

impl<E, T, Encoding, Request> IntoReq<Post<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

ยง

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
ยง

impl<E, T, Encoding, Request> IntoReq<Put<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

ยง

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
ยง

impl<E, Response, Encoding, T> IntoRes<Patch<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

ยง

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
ยง

impl<E, Response, Encoding, T> IntoRes<Post<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

ยง

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
ยง

impl<E, Response, Encoding, T> IntoRes<Put<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

ยง

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Sourceยง

impl<T> IntoStimulus<T> for T

Sourceยง

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
ยง

impl<T> Pointable for T

ยง

const ALIGN: usize

The alignment of pointer.
ยง

type Init = T

The type for initializers.
ยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
ยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
ยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
ยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
ยง

impl<T> Pointee for T

ยง

type Metadata = ()

The type for metadata in pointers and references to Self.
ยง

impl<T> PolicyExt for T
where T: ?Sized,

ยง

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
ยง

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
ยง

impl<T> SerializableKey for T

ยง

fn ser_key(&self) -> String

Serializes the key to a unique string. Read more
ยง

impl<T> StorageAccess<T> for T

ยง

fn as_borrowed(&self) -> &T

Borrows the value.
ยง

fn into_taken(self) -> T

Takes the value.
Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

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, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Sourceยง

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Sourceยง

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

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

Sourceยง

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.
Sourceยง

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Sourceยง

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Sourceยง

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Sourceยง

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Sourceยง

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Sourceยง

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
ยง

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

ยง

fn vzip(self) -> V

ยง

impl<T> WithSubscriber for T

ยง

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
ยง

fn with_current_subscriber(self) -> WithDispatch<Self> โ“˜

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
ยง

impl<T> ErasedDestructor for T
where T: 'static,

ยง

impl<T> Fruit for T
where T: Send + Downcast,