[][src]Trait http_api_problem::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.

Implementations on Foreign Types

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

impl HttpTryFrom<Bytes> for HeaderValue[src][]

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

impl HttpTryFrom<u64> for HeaderValue[src][]

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

impl HttpTryFrom<String> for Uri[src][]

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

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

impl HttpTryFrom<Bytes> for HeaderName[src][]

impl HttpTryFrom<HeaderName> for HeaderValue[src][]

impl HttpTryFrom<Bytes> for PathAndQuery[src][]

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

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

impl HttpTryFrom<Uri> for Uri[src][]

impl HttpTryFrom<HeaderValue> for HeaderValue[src][]

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

impl HttpTryFrom<Method> for Method[src][]

impl HttpTryFrom<i16> for HeaderValue[src][]

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

impl HttpTryFrom<Parts> for Uri[src][]

impl HttpTryFrom<u16> for HeaderValue[src][]

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

impl HttpTryFrom<String> for HeaderValue[src][]

impl HttpTryFrom<Bytes> for Authority[src][]

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");

impl HttpTryFrom<Authority> for Authority[src][]

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

impl HttpTryFrom<Scheme> for Scheme[src][]

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

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

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

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

impl HttpTryFrom<i64> for HeaderValue[src][]

impl HttpTryFrom<usize> for HeaderValue[src][]

impl HttpTryFrom<HeaderName> for HeaderName[src][]

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

impl HttpTryFrom<PathAndQuery> for PathAndQuery[src][]

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

impl HttpTryFrom<i32> for HeaderValue[src][]

impl HttpTryFrom<Bytes> for Uri[src][]

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

impl HttpTryFrom<isize> for HeaderValue[src][]

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

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

impl HttpTryFrom<Bytes> for Scheme[src][]

impl HttpTryFrom<u32> for HeaderValue[src][]

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

Implementors