[][src]Trait http::HttpTryFrom

pub trait HttpTryFrom<T>: Sized + 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...

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]

type Error = InvalidStatusCode

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<Bytes> for HeaderName[src]

type Error = InvalidHeaderNameBytes

impl HttpTryFrom<Bytes> for HeaderValue[src]

type Error = InvalidHeaderValueBytes

impl HttpTryFrom<Bytes> for Authority[src]

type Error = InvalidUriBytes

impl HttpTryFrom<Bytes> for PathAndQuery[src]

type Error = InvalidUriBytes

impl HttpTryFrom<Bytes> for Scheme[src]

type Error = InvalidUriBytes

impl HttpTryFrom<Bytes> for Uri[src]

type Error = InvalidUriBytes

impl HttpTryFrom<HeaderName> for HeaderName[src]

type Error = Error

impl HttpTryFrom<HeaderName> for HeaderValue[src]

impl HttpTryFrom<HeaderValue> for HeaderValue[src]

type Error = Error

impl HttpTryFrom<Method> for Method[src]

type Error = Error

impl HttpTryFrom<StatusCode> for StatusCode[src]

type Error = Error

impl HttpTryFrom<Authority> for Authority[src]

type Error = Error

impl HttpTryFrom<Parts> for Uri[src]

type Error = InvalidUriParts

impl HttpTryFrom<PathAndQuery> for PathAndQuery[src]

type Error = Error

impl HttpTryFrom<Scheme> for Scheme[src]

type Error = Error

impl HttpTryFrom<Uri> for Uri[src]

type Error = Error

impl HttpTryFrom<String> for HeaderValue[src]

impl HttpTryFrom<String> for Uri[src]

type Error = InvalidUriBytes

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

type Error = InvalidHeaderName

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

type Error = InvalidHeaderValue

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

type Error = InvalidMethod

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

type Error = InvalidStatusCode

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

type Error = InvalidUri

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

type Error = InvalidUri

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

type Error = InvalidUri

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

type Error = InvalidUri

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

type Error = Never

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

type Error = Never

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]

type Error = InvalidHeaderName

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

type Error = InvalidHeaderValue

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

type Error = InvalidUri

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

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

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

type Error = InvalidMethod

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

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

type Error = InvalidUri

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

type Error = InvalidUri

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

type Error = InvalidUri

impl<'a, K, V, T> HttpTryFrom<&'a HashMap<K, V, RandomState>> for HeaderMap<T> where
    K: Eq + Hash,
    HeaderName: HttpTryFrom<&'a K>,
    T: HttpTryFrom<&'a V>, 
[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

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

type Error = Error

Loading content...