[][src]Trait awc::http::HttpTryFrom

pub trait HttpTryFrom<T>: Sealed {
    type Error: Into<Error>;
}

Private trait for the http crate to have generic methods with fallible conversions.

This trait is similar to the TryFrom trait proposed in the standard library, except this is specialized for the http crate and isn't intended for general consumption.

This trait cannot be implemented types outside of the http crate, and is only intended for use as a generic bound on methods in the http crate.

Associated Types

type Error: Into<Error>

Associated error with the conversion this implementation represents.

Loading content...

Implementations on Foreign Types

impl<T> HttpTryFrom<HeaderMap<T>> for HeaderMap<T>[src]

type Error = Error

impl<'a, K, V, T> HttpTryFrom<&'a HashMap<K, V, RandomState>> for HeaderMap<T> where
    K: Eq + Hash,
    T: HttpTryFrom<&'a V>,
    HeaderName: HttpTryFrom<&'a K>, 
[src]

Try to convert a HashMap into a HeaderMap.

Examples

use std::collections::HashMap;
use http::{HttpTryFrom, header::HeaderMap};

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

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

type Error = Error

Loading content...

Implementors

impl HttpTryFrom<i16> for HeaderValue[src]

type Error = Never

impl HttpTryFrom<i32> for HeaderValue[src]

type Error = Never

impl HttpTryFrom<i64> for HeaderValue[src]

type Error = Never

impl HttpTryFrom<isize> for HeaderValue[src]

type Error = Never

impl HttpTryFrom<u16> for HeaderValue[src]

type Error = Never

impl HttpTryFrom<u16> for StatusCode[src]

impl HttpTryFrom<u32> for HeaderValue[src]

type Error = Never

impl HttpTryFrom<u64> for HeaderValue[src]

type Error = Never

impl HttpTryFrom<usize> for HeaderValue[src]

type Error = Never

impl HttpTryFrom<HeaderName> for HeaderName[src]

impl HttpTryFrom<HeaderName> for HeaderValue[src]

impl HttpTryFrom<HeaderValue> for HeaderValue[src]

impl HttpTryFrom<Method> for Method[src]

impl HttpTryFrom<PathAndQuery> for PathAndQuery[src]

impl HttpTryFrom<StatusCode> for StatusCode[src]

impl HttpTryFrom<Uri> for Uri[src]

impl HttpTryFrom<Authority> for Authority[src]

impl HttpTryFrom<Parts> for Uri[src]

impl HttpTryFrom<Scheme> for Scheme[src]

impl HttpTryFrom<String> for HeaderValue[src]

impl HttpTryFrom<String> for Uri[src]

impl HttpTryFrom<Bytes> for Uri[src]

impl HttpTryFrom<Bytes> for HeaderValue[src]

impl HttpTryFrom<Bytes> for Scheme[src]

impl HttpTryFrom<Bytes> for Authority[src]

impl HttpTryFrom<Bytes> for PathAndQuery[src]

impl HttpTryFrom<Bytes> for HeaderName[src]

impl<'a> HttpTryFrom<&'a str> for HeaderName[src]

impl<'a> HttpTryFrom<&'a str> for HeaderValue[src]

impl<'a> HttpTryFrom<&'a str> for Method[src]

type Error = InvalidMethod

impl<'a> HttpTryFrom<&'a str> for PathAndQuery[src]

impl<'a> HttpTryFrom<&'a str> for StatusCode[src]

impl<'a> HttpTryFrom<&'a str> for Uri[src]

type Error = InvalidUri

impl<'a> HttpTryFrom<&'a str> for Authority[src]

type Error = InvalidUri

impl<'a> HttpTryFrom<&'a str> for Scheme[src]

type Error = InvalidUri

impl<'a> HttpTryFrom<&'a HeaderName> for HeaderName[src]

type Error = Never

impl<'a> HttpTryFrom<&'a HeaderValue> for HeaderValue[src]

impl<'a> HttpTryFrom<&'a Method> for Method[src]

type Error = Never

impl<'a> HttpTryFrom<&'a StatusCode> for StatusCode[src]

type Error = Never

impl<'a> HttpTryFrom<&'a Uri> for Uri[src]

type Error = Error

impl<'a> HttpTryFrom<&'a String> for HeaderName[src]

impl<'a> HttpTryFrom<&'a String> for HeaderValue[src]

impl<'a> HttpTryFrom<&'a String> for Uri[src]

type Error = InvalidUri

impl<'a> HttpTryFrom<&'a [u8]> for PathAndQuery[src]

impl<'a> HttpTryFrom<&'a [u8]> for Authority[src]

impl<'a> HttpTryFrom<&'a [u8]> for HeaderValue[src]

impl<'a> HttpTryFrom<&'a [u8]> for HeaderName[src]

impl<'a> HttpTryFrom<&'a [u8]> for Scheme[src]

impl<'a> HttpTryFrom<&'a [u8]> for Method[src]

impl<'a> HttpTryFrom<&'a [u8]> for StatusCode[src]

Loading content...