[][src]Trait fastly::convert::ToHeaderValue

pub trait ToHeaderValue: Sealed { }

Types that can be converted to a HeaderValue.

Some methods in this crate accept impl ToHeaderValue arguments. Any of the types below can be passed as those arguments and the conversion will be performed automatically, though depending on the type, the conversion can panic.

Source typeCan panic?Non-panicking conversion
HeaderName or &HeaderNameNoN/A
HeaderValue or &HeaderValueNoN/A
Url or &UrlNoN/A
&str, String, or &StringYesHeaderValue::try_from()
&[u8], Vec<u8>, or &Vec<u8>YesHeaderValue::try_from()

Panics

This conversion trait differs from std::convert::Into, which is guaranteed to succeed for any argument, and std::convert::TryInto which returns an explicit error when a conversion fails.

For types marked above as Can panic?, the conversion may panic at runtime if the data is invalid. Automatic conversions for these types are provided for convenience for data you trust, like a string literal in your code, or for applications where a default 500 Internal Server Error response for a conversion failure is acceptable.

In most applications you should explicitly convert data from untrusted sources, such as the client request, to one of the types that cannot fail at runtime using a method like those listed under Non-panicking conversion. This allows your application to handle conversion errors without panicking, such as by falling back on a default value, removing invalid characters, or returning a branded error page.

Implementations on Foreign Types

impl ToHeaderValue for &str[src]

impl ToHeaderValue for String[src]

impl ToHeaderValue for &String[src]

impl ToHeaderValue for &[u8][src]

impl ToHeaderValue for Vec<u8>[src]

impl ToHeaderValue for &Vec<u8>[src]

Loading content...

Implementors

impl ToHeaderValue for &HeaderName[src]

impl ToHeaderValue for &Url[src]

impl ToHeaderValue for HeaderName[src]

impl ToHeaderValue for HeaderValue[src]

impl ToHeaderValue for Url[src]

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

Loading content...