Open
Description
A HeaderValue
may not always be a valid UTF-8 String
, and so there is a to_str(&self) -> Result<&str, ToStrError>
method that validates the bytes first. To create a String
, one could instead do String::from_utf8(value.as_bytes())
, but once you have that String
, you'll need to re-validate it to turn it back into a HeaderValue
.
It would be useful to have a type that represents being both a valid HeaderValue
and a valid String
at the same time. This type would have a free as_str()
method, since it's already been validated, and conversely a free into_value()
method (again, because it's already validated).