Trait http::HttpTryFrom
source · [−]Expand description
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
Implementors
sourceimpl HttpTryFrom<i16> for HeaderValue
impl HttpTryFrom<i16> for HeaderValue
type Error = Never
sourceimpl HttpTryFrom<i32> for HeaderValue
impl HttpTryFrom<i32> for HeaderValue
type Error = Never
sourceimpl HttpTryFrom<i64> for HeaderValue
impl HttpTryFrom<i64> for HeaderValue
type Error = Never
sourceimpl HttpTryFrom<isize> for HeaderValue
impl HttpTryFrom<isize> for HeaderValue
type Error = Never
sourceimpl HttpTryFrom<u16> for HeaderValue
impl HttpTryFrom<u16> for HeaderValue
type Error = Never
sourceimpl HttpTryFrom<u16> for StatusCode
impl HttpTryFrom<u16> for StatusCode
type Error = InvalidStatusCode
sourceimpl HttpTryFrom<u32> for HeaderValue
impl HttpTryFrom<u32> for HeaderValue
type Error = Never
sourceimpl HttpTryFrom<u64> for HeaderValue
impl HttpTryFrom<u64> for HeaderValue
type Error = Never
sourceimpl HttpTryFrom<usize> for HeaderValue
impl HttpTryFrom<usize> for HeaderValue
type Error = Never
sourceimpl HttpTryFrom<Bytes> for HeaderName
impl HttpTryFrom<Bytes> for HeaderName
type Error = InvalidHeaderNameBytes
sourceimpl HttpTryFrom<Bytes> for HeaderValue
impl HttpTryFrom<Bytes> for HeaderValue
type Error = InvalidHeaderValueBytes
sourceimpl HttpTryFrom<Bytes> for Authority
impl HttpTryFrom<Bytes> for Authority
type Error = InvalidUriBytes
sourceimpl HttpTryFrom<Bytes> for PathAndQuery
impl HttpTryFrom<Bytes> for PathAndQuery
type Error = InvalidUriBytes
sourceimpl HttpTryFrom<Bytes> for Scheme
impl HttpTryFrom<Bytes> for Scheme
type Error = InvalidUriBytes
sourceimpl HttpTryFrom<Bytes> for Uri
impl HttpTryFrom<Bytes> for Uri
type Error = InvalidUriBytes
sourceimpl HttpTryFrom<HeaderName> for HeaderName
impl HttpTryFrom<HeaderName> for HeaderName
sourceimpl HttpTryFrom<HeaderName> for HeaderValue
impl HttpTryFrom<HeaderName> for HeaderValue
type Error = InvalidHeaderValue
sourceimpl HttpTryFrom<HeaderValue> for HeaderValue
impl HttpTryFrom<HeaderValue> for HeaderValue
sourceimpl HttpTryFrom<String> for HeaderValue
impl HttpTryFrom<String> for HeaderValue
type Error = InvalidHeaderValueBytes
sourceimpl HttpTryFrom<String> for Uri
impl HttpTryFrom<String> for Uri
type Error = InvalidUriBytes
sourceimpl HttpTryFrom<StatusCode> for StatusCode
impl HttpTryFrom<StatusCode> for StatusCode
sourceimpl HttpTryFrom<Parts> for Uri
impl HttpTryFrom<Parts> for Uri
type Error = InvalidUriParts
sourceimpl HttpTryFrom<PathAndQuery> for PathAndQuery
impl HttpTryFrom<PathAndQuery> for PathAndQuery
sourceimpl<'a> HttpTryFrom<&'a str> for HeaderName
impl<'a> HttpTryFrom<&'a str> for HeaderName
type Error = InvalidHeaderName
sourceimpl<'a> HttpTryFrom<&'a str> for HeaderValue
impl<'a> HttpTryFrom<&'a str> for HeaderValue
type Error = InvalidHeaderValue
sourceimpl<'a> HttpTryFrom<&'a str> for Method
impl<'a> HttpTryFrom<&'a str> for Method
type Error = InvalidMethod
sourceimpl<'a> HttpTryFrom<&'a str> for StatusCode
impl<'a> HttpTryFrom<&'a str> for StatusCode
type Error = InvalidStatusCode
sourceimpl<'a> HttpTryFrom<&'a str> for Authority
impl<'a> HttpTryFrom<&'a str> for Authority
type Error = InvalidUri
sourceimpl<'a> HttpTryFrom<&'a str> for PathAndQuery
impl<'a> HttpTryFrom<&'a str> for PathAndQuery
type Error = InvalidUri
sourceimpl<'a> HttpTryFrom<&'a str> for Scheme
impl<'a> HttpTryFrom<&'a str> for Scheme
type Error = InvalidUri
sourceimpl<'a> HttpTryFrom<&'a str> for Uri
impl<'a> HttpTryFrom<&'a str> for Uri
type Error = InvalidUri
sourceimpl<'a> HttpTryFrom<&'a HeaderName> for HeaderName
impl<'a> HttpTryFrom<&'a HeaderName> for HeaderName
type Error = Never
sourceimpl<'a> HttpTryFrom<&'a HeaderValue> for HeaderValue
impl<'a> HttpTryFrom<&'a HeaderValue> for HeaderValue
type Error = Never
sourceimpl<'a> HttpTryFrom<&'a String> for HeaderName
impl<'a> HttpTryFrom<&'a String> for HeaderName
type Error = InvalidHeaderName
sourceimpl<'a> HttpTryFrom<&'a String> for HeaderValue
impl<'a> HttpTryFrom<&'a String> for HeaderValue
type Error = InvalidHeaderValue
sourceimpl<'a> HttpTryFrom<&'a String> for Uri
impl<'a> HttpTryFrom<&'a String> for Uri
type Error = InvalidUri
sourceimpl<'a> HttpTryFrom<&'a Method> for Method
impl<'a> HttpTryFrom<&'a Method> for Method
type Error = Never
sourceimpl<'a> HttpTryFrom<&'a StatusCode> for StatusCode
impl<'a> HttpTryFrom<&'a StatusCode> for StatusCode
type Error = Never
sourceimpl<'a> HttpTryFrom<&'a [u8]> for HeaderName
impl<'a> HttpTryFrom<&'a [u8]> for HeaderName
type Error = InvalidHeaderName
sourceimpl<'a> HttpTryFrom<&'a [u8]> for HeaderValue
impl<'a> HttpTryFrom<&'a [u8]> for HeaderValue
type Error = InvalidHeaderValue
sourceimpl<'a> HttpTryFrom<&'a [u8]> for Method
impl<'a> HttpTryFrom<&'a [u8]> for Method
type Error = InvalidMethod
sourceimpl<'a> HttpTryFrom<&'a [u8]> for StatusCode
impl<'a> HttpTryFrom<&'a [u8]> for StatusCode
type Error = InvalidStatusCode
sourceimpl<'a> HttpTryFrom<&'a [u8]> for Authority
impl<'a> HttpTryFrom<&'a [u8]> for Authority
type Error = InvalidUri
sourceimpl<'a> HttpTryFrom<&'a [u8]> for PathAndQuery
impl<'a> HttpTryFrom<&'a [u8]> for PathAndQuery
type Error = InvalidUri
sourceimpl<'a> HttpTryFrom<&'a [u8]> for Scheme
impl<'a> HttpTryFrom<&'a [u8]> for Scheme
type Error = InvalidUri
sourceimpl<'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>,
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>,
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");